X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FDoctrineMigrations%2FVersion20160812120952.php;h=13272267046514d58c502b54d9af4d09453d27b0;hb=873f6b8e03079d11fab541aa5b0bc6f8fe2d645e;hp=9adfdc8be35e87f66fcc49fac5c161e56ef1ae75;hpb=637aa17e6b52dd8021854a809053560a27caca72;p=github%2Fwallabag%2Fwallabag.git diff --git a/app/DoctrineMigrations/Version20160812120952.php b/app/DoctrineMigrations/Version20160812120952.php index 9adfdc8b..13272267 100644 --- a/app/DoctrineMigrations/Version20160812120952.php +++ b/app/DoctrineMigrations/Version20160812120952.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * Added name field on wallabag_oauth2_clients. + */ class Version20160812120952 extends AbstractMigration implements ContainerAwareInterface { /** @@ -21,7 +24,7 @@ class Version20160812120952 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 +32,10 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI */ public function up(Schema $schema) { - $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name longtext COLLATE \'utf8_unicode_ci\' DEFAULT NULL'); + $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); + $this->skipIf($clientsTable->hasColumn('name'), 'It seems that you already played this migration.'); + + $clientsTable->addColumn('name', 'blob'); } /** @@ -37,8 +43,7 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI */ public function down(Schema $schema) { - $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); - - $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' DROP COLUMN name'); + $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); + $clientsTable->dropColumn('name'); } }