aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20160911214952.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/DoctrineMigrations/Version20160911214952.php')
-rw-r--r--app/DoctrineMigrations/Version20160911214952.php28
1 files changed, 25 insertions, 3 deletions
diff --git a/app/DoctrineMigrations/Version20160911214952.php b/app/DoctrineMigrations/Version20160911214952.php
index f14f7bc6..edef81ed 100644
--- a/app/DoctrineMigrations/Version20160911214952.php
+++ b/app/DoctrineMigrations/Version20160911214952.php
@@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface; 7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface; 8use Symfony\Component\DependencyInjection\ContainerInterface;
9 9
10/**
11 * Added settings for RabbitMQ and Redis imports
12 */
10class Version20160911214952 extends AbstractMigration implements ContainerAwareInterface 13class Version20160911214952 extends AbstractMigration implements ContainerAwareInterface
11{ 14{
12 /** 15 /**
@@ -21,7 +24,7 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
21 24
22 private function getTable($tableName) 25 private function getTable($tableName)
23 { 26 {
24 return $this->container->getParameter('database_table_prefix') . $tableName; 27 return $this->container->getParameter('database_table_prefix').$tableName;
25 } 28 }
26 29
27 /** 30 /**
@@ -29,8 +32,25 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
29 */ 32 */
30 public function up(Schema $schema) 33 public function up(Schema $schema)
31 { 34 {
32 $this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting').'" (name, value, section) VALUES (\'import_with_redis\', \'0\', \'import\')'); 35 $redis = $this->container
33 $this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting').'" (name, value, section) VALUES (\'import_with_rabbitmq\', \'0\', \'import\')'); 36 ->get('doctrine.orm.default_entity_manager')
37 ->getConnection()
38 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis'");
39
40 if (false === $redis) {
41 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_redis', 0, 'import')");
42 }
43
44 $rabbitmq = $this->container
45 ->get('doctrine.orm.default_entity_manager')
46 ->getConnection()
47 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq'");
48
49 if (false === $rabbitmq) {
50 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_rabbitmq', 0, 'import')");
51 }
52
53 $this->skipIf(false !== $rabbitmq && false !== $redis, 'It seems that you already played this migration.');
34 } 54 }
35 55
36 /** 56 /**
@@ -38,5 +58,7 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
38 */ 58 */
39 public function down(Schema $schema) 59 public function down(Schema $schema)
40 { 60 {
61 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis';");
62 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq';");
41 } 63 }
42} 64}