diff options
Diffstat (limited to 'app/DoctrineMigrations/Version20161024212538.php')
-rw-r--r-- | app/DoctrineMigrations/Version20161024212538.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/DoctrineMigrations/Version20161024212538.php b/app/DoctrineMigrations/Version20161024212538.php index ced3a802..7e79cbde 100644 --- a/app/DoctrineMigrations/Version20161024212538.php +++ b/app/DoctrineMigrations/Version20161024212538.php | |||
@@ -29,12 +29,18 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI | |||
29 | */ | 29 | */ |
30 | public function up(Schema $schema) | 30 | public function up(Schema $schema) |
31 | { | 31 | { |
32 | $this->skipIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); | 32 | $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); |
33 | 33 | ||
34 | $this->skipIf($schema->getTable($this->getTable('oauth2_clients'))->hasColumn('user_id'), 'It seems that you already played this migration.'); | 34 | $this->skipIf($clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.'); |
35 | 35 | ||
36 | $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD user_id INT(11) DEFAULT NULL'); | 36 | $clientsTable->addColumn('user_id', 'integer'); |
37 | $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD CONSTRAINT FK_clients_user_clients FOREIGN KEY (user_id) REFERENCES '.$this->getTable('user').' (id) ON DELETE CASCADE'); | 37 | |
38 | $clientsTable->addForeignKeyConstraint( | ||
39 | $this->getTable('user'), | ||
40 | array('user_id'), | ||
41 | array('id'), | ||
42 | array('onDelete' => 'CASCADE') | ||
43 | ); | ||
38 | } | 44 | } |
39 | 45 | ||
40 | /** | 46 | /** |