aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20161024212538.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/DoctrineMigrations/Version20161024212538.php')
-rw-r--r--app/DoctrineMigrations/Version20161024212538.php16
1 files changed, 14 insertions, 2 deletions
diff --git a/app/DoctrineMigrations/Version20161024212538.php b/app/DoctrineMigrations/Version20161024212538.php
index 0c5a53da..ecb872d1 100644
--- a/app/DoctrineMigrations/Version20161024212538.php
+++ b/app/DoctrineMigrations/Version20161024212538.php
@@ -17,6 +17,8 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
17 */ 17 */
18 private $container; 18 private $container;
19 19
20 private $constraintName = 'IDX_user_oauth_client';
21
20 public function setContainer(ContainerInterface $container = null) 22 public function setContainer(ContainerInterface $container = null)
21 { 23 {
22 $this->container = $container; 24 $this->container = $container;
@@ -36,13 +38,14 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
36 38
37 $this->skipIf($clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.'); 39 $this->skipIf($clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.');
38 40
39 $clientsTable->addColumn('user_id', 'integer'); 41 $clientsTable->addColumn('user_id', 'integer', ['notnull' => false]);
40 42
41 $clientsTable->addForeignKeyConstraint( 43 $clientsTable->addForeignKeyConstraint(
42 $this->getTable('user'), 44 $this->getTable('user'),
43 ['user_id'], 45 ['user_id'],
44 ['id'], 46 ['id'],
45 ['onDelete' => 'CASCADE'] 47 ['onDelete' => 'CASCADE'],
48 $this->constraintName
46 ); 49 );
47 } 50 }
48 51
@@ -51,5 +54,14 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
51 */ 54 */
52 public function down(Schema $schema) 55 public function down(Schema $schema)
53 { 56 {
57 $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
58
59 $this->skipIf(!$clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.');
60
61 $clientsTable->dropColumn('user_id', 'integer');
62
63 if ($this->connection->getDatabasePlatform()->getName() != 'sqlite') {
64 $clientsTable->removeForeignKey($this->constraintName);
65 }
54 } 66 }
55} 67}