X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FDoctrineMigrations%2FVersion20161106113822.php;h=5032a8f0563e3cfbe229e5e75dcdeadd9612194f;hb=68cb89a5161351dd730871fc834bf147204a2a07;hp=edca54f5d732348dfb277362fffc22da52adadcf;hpb=eb2d613c3ed95d741e987917f976da349ea240eb;p=github%2Fwallabag%2Fwallabag.git diff --git a/app/DoctrineMigrations/Version20161106113822.php b/app/DoctrineMigrations/Version20161106113822.php index edca54f5..5032a8f0 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,13 @@ 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, + ]); } /** @@ -37,8 +43,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'); } }