forked from wallabag/wallabag
Added hardcoded SQL for migration to 2.2
This commit is contained in:
@ -17,6 +17,8 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
|
||||
*/
|
||||
private $container;
|
||||
|
||||
private $constraintName = 'IDX_user_oauth_client';
|
||||
|
||||
public function setContainer(ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
@ -36,13 +38,14 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
|
||||
|
||||
$this->skipIf($clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.');
|
||||
|
||||
$clientsTable->addColumn('user_id', 'integer');
|
||||
$clientsTable->addColumn('user_id', 'integer', ['notnull' => false]);
|
||||
|
||||
$clientsTable->addForeignKeyConstraint(
|
||||
$this->getTable('user'),
|
||||
['user_id'],
|
||||
['id'],
|
||||
['onDelete' => 'CASCADE']
|
||||
['onDelete' => 'CASCADE'],
|
||||
$this->constraintName
|
||||
);
|
||||
}
|
||||
|
||||
@ -51,5 +54,14 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
$clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
|
||||
|
||||
$this->skipIf(!$clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.');
|
||||
|
||||
$clientsTable->dropColumn('user_id', 'integer');
|
||||
|
||||
if ($this->connection->getDatabasePlatform()->getName() != 'sqlite') {
|
||||
$clientsTable->removeForeignKey($this->constraintName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user