X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FDoctrineMigrations%2FVersion20161118134328.php;h=dab0ff5b47b96020734a3602c74da5206ebb35d4;hb=refs%2Fheads%2Furl-3529;hp=76dd90742e7bfd7f4c4733a1a75d93a05d1cd1ec;hpb=18d7bc3a353d8737c64a0f9e1c9fdcb7a756c3e5;p=github%2Fwallabag%2Fwallabag.git diff --git a/app/DoctrineMigrations/Version20161118134328.php b/app/DoctrineMigrations/Version20161118134328.php index 76dd9074..dab0ff5b 100644 --- a/app/DoctrineMigrations/Version20161118134328.php +++ b/app/DoctrineMigrations/Version20161118134328.php @@ -22,19 +22,19 @@ class Version20161118134328 extends AbstractMigration implements ContainerAwareI $this->container = $container; } - private function getTable($tableName) - { - return $this->container->getParameter('database_table_prefix').$tableName; - } - /** * @param Schema $schema */ public function up(Schema $schema) { - $this->skipIf($schema->getTable($this->getTable('entry'))->hasColumn('http_status'), 'It seems that you already played this migration.'); + $entryTable = $schema->getTable($this->getTable('entry')); + + $this->skipIf($entryTable->hasColumn('http_status'), 'It seems that you already played this migration.'); - $this->addSql('ALTER TABLE '.$this->getTable('entry').' ADD http_status VARCHAR(3) DEFAULT NULL'); + $entryTable->addColumn('http_status', 'string', [ + 'length' => 3, + 'notnull' => false, + ]); } /** @@ -42,8 +42,15 @@ class Version20161118134328 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.'); + $entryTable = $schema->getTable($this->getTable('entry')); - $this->addSql('ALTER TABLE '.$this->getTable('entry').' DROP http_status'); + $this->skipIf(!$entryTable->hasColumn('http_status'), 'It seems that you already played this migration.'); + + $entryTable->dropColumn('http_status'); + } + + private function getTable($tableName) + { + return $this->container->getParameter('database_table_prefix') . $tableName; } }