]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - app/DoctrineMigrations/Version20161122203647.php
Merge remote-tracking branch 'origin/master' into 2.3
[github/wallabag/wallabag.git] / app / DoctrineMigrations / Version20161122203647.php
index 9c1557ebc3a54f922b0de8b88da6ec8dd73a6149..ef08bd59d5f511f82e4acc38f63f7b54db05d6ae 100644 (file)
@@ -30,11 +30,6 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
         $this->container = $container;
     }
 
-    private function getTable($tableName)
-    {
-        return $this->container->getParameter('database_table_prefix').$tableName;
-    }
-
     /**
      * @param Schema $schema
      */
@@ -42,12 +37,9 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
     {
         $userTable = $schema->getTable($this->getTable('user'));
 
-        $this->skipIf(false === $userTable->hasColumn('expired'), 'It seems that you already played this migration.');
+        $this->skipIf(false === $userTable->hasColumn('expired') || false === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.');
 
         $userTable->dropColumn('expired');
-
-        $this->skipIf(false === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.');
-
         $userTable->dropColumn('credentials_expired');
     }
 
@@ -57,7 +49,15 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
     public function down(Schema $schema)
     {
         $userTable = $schema->getTable($this->getTable('user'));
-        $userTable->addColumn('expired', 'smallint');
-        $userTable->addColumn('credentials_expired', 'smallint');
+
+        $this->skipIf(true === $userTable->hasColumn('expired') || true === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.');
+
+        $userTable->addColumn('expired', 'smallint', ['notnull' => false]);
+        $userTable->addColumn('credentials_expired', 'smallint', ['notnull' => false]);
+    }
+
+    private function getTable($tableName)
+    {
+        return $this->container->getParameter('database_table_prefix') . $tableName;
     }
 }