Cleaned old migrations

This commit is contained in:
Nicolas Lœuillet
2016-11-26 16:06:14 +01:00
parent 84c6a48df4
commit 597755b8c7
4 changed files with 26 additions and 35 deletions

View File

@ -29,20 +29,10 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI
*/
public function up(Schema $schema)
{
$this->skipIf($schema->getTable($this->getTable('oauth2_clients'))->hasColumn('name'), 'It seems that you already played this migration.');
$clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
$this->skipIf($clientsTable->hasColumn('name'), 'It seems that you already played this migration.');
switch ($this->connection->getDatabasePlatform()->getName()) {
case 'sqlite':
$this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name longtext DEFAULT NULL');
break;
case 'mysql':
$this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name longtext COLLATE \'utf8_unicode_ci\' DEFAULT NULL');
break;
case 'postgresql':
$this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name text DEFAULT NULL');
}
$clientsTable->addColumn('name', 'blob');
}
/**
@ -50,8 +40,7 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI
*/
public function down(Schema $schema)
{
$this->skipIf($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');
}
}