3 namespace Application\Migrations
;
5 use Doctrine\DBAL\Schema\Schema
;
6 use Wallabag\CoreBundle\Doctrine\WallabagMigration
;
9 * Added user_id column on oauth2_clients to prevent users to delete API clients from other users.
11 class Version20161024212538
extends WallabagMigration
13 private $constraintName = 'IDX_user_oauth_client';
16 * @param Schema $schema
18 public function up(Schema
$schema)
20 $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
22 $this->skipIf($clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.');
24 $clientsTable->addColumn('user_id', 'integer', ['notnull' => false]);
26 $clientsTable->addForeignKeyConstraint(
27 $this->getTable('user'),
30 ['onDelete' => 'CASCADE'],
36 * @param Schema $schema
38 public function down(Schema
$schema)
40 $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
42 $this->skipIf(!$clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.');
44 $clientsTable->dropColumn('user_id', 'integer');
46 if ('sqlite' !== $this->connection
->getDatabasePlatform()->getName()) {
47 $clientsTable->removeForeignKey($this->constraintName
);