X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=app%2FDoctrineMigrations%2FVersion20161106113822.php;h=55bd87a2ccba18a2a85c2b9ff87bf4bfb03c093d;hb=c8ef0583af9592d4a18eed7913b81fa664cd8397;hp=edca54f5d732348dfb277362fffc22da52adadcf;hpb=66336f65714433996bb5574662d50d9a8cf03aff;p=github%2Fwallabag%2Fwallabag.git diff --git a/app/DoctrineMigrations/Version20161106113822.php b/app/DoctrineMigrations/Version20161106113822.php index edca54f5..55bd87a2 100644 --- a/app/DoctrineMigrations/Version20161106113822.php +++ b/app/DoctrineMigrations/Version20161106113822.php @@ -21,7 +21,7 @@ class Version20161106113822 extends AbstractMigration implements ContainerAwareI private function getTable($tableName) { - return $this->container->getParameter('database_table_prefix') . $tableName; + return $this->container->getParameter('database_table_prefix').$tableName; } /** @@ -29,7 +29,14 @@ class Version20161106113822 extends AbstractMigration implements ContainerAwareI */ public function up(Schema $schema) { - $this->addSql('ALTER TABLE '.$this->getTable('config').' ADD action_mark_as_read INT DEFAULT 0'); + $configTable = $schema->getTable($this->getTable('config')); + + $this->skipIf($configTable->hasColumn('action_mark_as_read'), 'It seems that you already played this migration.'); + + $configTable->addColumn('action_mark_as_read', 'integer', [ + 'default' => 0, + 'notnull' => false, + ]); } /** @@ -37,8 +44,7 @@ class Version20161106113822 extends AbstractMigration implements ContainerAwareI */ public function down(Schema $schema) { - $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.'); - - $this->addSql('ALTER TABLE '.$this->getTable('config').' DROP action_mark_as_read'); + $configTable = $schema->getTable($this->getTable('config')); + $userTable->dropColumn('action_mark_as_read'); } }