]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Ensure craue_config_setting migration are ok
authorJeremy Benoist <jeremy.benoist@gmail.com>
Sun, 4 Dec 2016 11:56:20 +0000 (12:56 +0100)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Thu, 15 Dec 2016 21:25:10 +0000 (22:25 +0100)
We now can run the migration every time, new line from `craue_config_setting` are properly checked.

app/DoctrineMigrations/Version20160911214952.php
app/DoctrineMigrations/Version20161031132655.php
app/DoctrineMigrations/Version20161117071626.php
app/DoctrineMigrations/Version20161122144743.php

index 963821ae81ee6c4cf1c97661a2bcae2eeed642fe..7b85dc5e5c5ebfe7067ce3b8eb283e2de7b482f5 100644 (file)
@@ -29,8 +29,25 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
      */
     public function up(Schema $schema)
     {
-        $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_redis', 0, 'import')");
-        $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_rabbitmq', 0, 'import')");
+        $redis = $this->container
+            ->get('doctrine.orm.default_entity_manager')
+            ->getConnection()
+            ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting').' WHERE name = "import_with_redis"');
+
+        if (false === $redis) {
+            $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_redis', 0, 'import')");
+        }
+
+        $rabbitmq = $this->container
+            ->get('doctrine.orm.default_entity_manager')
+            ->getConnection()
+            ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting').' WHERE name = "import_with_rabbitmq"');
+
+        if (false === $rabbitmq) {
+            $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_rabbitmq', 0, 'import')");
+        }
+
+        $this->skipIf(false !== $rabbitmq && false !== $redis, 'It seems that you already played this migration.');
     }
 
     /**
index 39b85ea9759f979a913ea0fb84271ebe46914762..89b660183d87da669972a1e8572440ad4977cb07 100644 (file)
@@ -29,6 +29,13 @@ class Version20161031132655 extends AbstractMigration implements ContainerAwareI
      */
     public function up(Schema $schema)
     {
+        $images = $this->container
+            ->get('doctrine.orm.default_entity_manager')
+            ->getConnection()
+            ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting').' WHERE name = "download_images_enabled"');
+
+        $this->skipIf(false !== $images, 'It seems that you already played this migration.');
+
         $this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('download_images_enabled', 0, 'misc')");
     }
 
index 33f5707ebe070a9b81684516e87a95ece9f03258..e65598a9b16d210da178a641f451811798f06792 100644 (file)
@@ -29,8 +29,25 @@ class Version20161117071626 extends AbstractMigration implements ContainerAwareI
      */
     public function up(Schema $schema)
     {
-        $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_unmark', 0, 'entry')");
-        $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')");
+        $share = $this->container
+            ->get('doctrine.orm.default_entity_manager')
+            ->getConnection()
+            ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting').' WHERE name = "share_unmark"');
+
+        if (false === $share) {
+            $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_unmark', 0, 'entry')");
+        }
+
+        $unmark = $this->container
+            ->get('doctrine.orm.default_entity_manager')
+            ->getConnection()
+            ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting').' WHERE name = "unmark_url"');
+
+        if (false === $unmark) {
+            $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')");
+        }
+
+        $this->skipIf(false !== $share && false !== $unmark, 'It seems that you already played this migration.');
     }
 
     /**
index 536b833993539f2f3755c529042d8016dd15c2e8..02113031c838fb90cc2a2cab3d39ac41966185ce 100644 (file)
@@ -32,6 +32,13 @@ class Version20161122144743 extends AbstractMigration implements ContainerAwareI
      */
     public function up(Schema $schema)
     {
+        $access = $this->container
+            ->get('doctrine.orm.default_entity_manager')
+            ->getConnection()
+            ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting').' WHERE name = "restricted_access"');
+
+        $this->skipIf(false !== $access, 'It seems that you already played this migration.');
+
         $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('restricted_access', 0, 'entry')");
     }