aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20161024212538.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2017-01-23 14:16:00 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2017-01-23 14:16:00 +0100
commit4acbeb93717612f361627f7d4b946fcb4477823c (patch)
treecf5856dce4a254535a9ea862ca7b072fcf0424b9 /app/DoctrineMigrations/Version20161024212538.php
parentb87f1712336564ec14e37487f512568bc4d986f7 (diff)
downloadwallabag-4acbeb93717612f361627f7d4b946fcb4477823c.tar.gz
wallabag-4acbeb93717612f361627f7d4b946fcb4477823c.tar.zst
wallabag-4acbeb93717612f361627f7d4b946fcb4477823c.zip
Added hardcoded SQL for migration to 2.2
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}