X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FDoctrineMigrations%2FVersion20161122203647.php;h=9b17d6efddfc90547bd02c5f2dc0de527ee7272d;hb=822c877949aff8ae57677671115f8f4fc69588d5;hp=2cb990e1e884cdaf38effff3bc72b980756f6276;hpb=18d7bc3a353d8737c64a0f9e1c9fdcb7a756c3e5;p=github%2Fwallabag%2Fwallabag.git diff --git a/app/DoctrineMigrations/Version20161122203647.php b/app/DoctrineMigrations/Version20161122203647.php index 2cb990e1..9b17d6ef 100644 --- a/app/DoctrineMigrations/Version20161122203647.php +++ b/app/DoctrineMigrations/Version20161122203647.php @@ -40,15 +40,12 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI */ public function up(Schema $schema) { - $this->abortIf($this->connection->getDatabasePlatform()->getName() === 'sqlite', 'This up migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.'); + $userTable = $schema->getTable($this->getTable('user')); - $this->skipIf(false === $schema->getTable($this->getTable('user'))->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.'); - $this->addSql('ALTER TABLE '.$this->getTable('user').' DROP expired'); - - $this->skipIf(false === $schema->getTable($this->getTable('user'))->hasColumn('credentials_expired'), 'It seems that you already played this migration.'); - - $this->addSql('ALTER TABLE '.$this->getTable('user').' DROP credentials_expired'); + $userTable->dropColumn('expired'); + $userTable->dropColumn('credentials_expired'); } /** @@ -56,7 +53,11 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI */ public function down(Schema $schema) { - $this->addSql('ALTER TABLE '.$this->getTable('user').' ADD expired tinyint(1) NULL DEFAULT 0'); - $this->addSql('ALTER TABLE '.$this->getTable('user').' ADD credentials_expired tinyint(1) NULL DEFAULT 0'); + $userTable = $schema->getTable($this->getTable('user')); + + $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]); } }