container = $container; } /** * @param Schema $schema */ public function up(Schema $schema) { $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); $this->skipIf($clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.'); $clientsTable->addColumn('user_id', 'integer', ['notnull' => false]); $clientsTable->addForeignKeyConstraint( $this->getTable('user'), ['user_id'], ['id'], ['onDelete' => 'CASCADE'], $this->constraintName ); } /** * @param Schema $schema */ 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); } } private function getTable($tableName) { return $this->container->getParameter('database_table_prefix') . $tableName; } }