aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20161024212538.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2017-01-26 13:15:06 +0100
committerGitHub <noreply@github.com>2017-01-26 13:15:06 +0100
commit463cb376e357d50c5913452fba68a70bf43492c9 (patch)
treeec6ae907d00b7637c0a3238943e6ffcb78802924 /app/DoctrineMigrations/Version20161024212538.php
parent012b2d453e0cbe1ab478c2868559f919ea805db2 (diff)
parent5d916d03afaec6fbe32d2a95624628096325744e (diff)
downloadwallabag-463cb376e357d50c5913452fba68a70bf43492c9.tar.gz
wallabag-463cb376e357d50c5913452fba68a70bf43492c9.tar.zst
wallabag-463cb376e357d50c5913452fba68a70bf43492c9.zip
Merge pull request #2646 from wallabag/explain-migrations-in-doc
Added explanations about migrations
Diffstat (limited to 'app/DoctrineMigrations/Version20161024212538.php')
-rw-r--r--app/DoctrineMigrations/Version20161024212538.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/app/DoctrineMigrations/Version20161024212538.php b/app/DoctrineMigrations/Version20161024212538.php
index 75ff86f1..ecb872d1 100644
--- a/app/DoctrineMigrations/Version20161024212538.php
+++ b/app/DoctrineMigrations/Version20161024212538.php
@@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface; 7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface; 8use Symfony\Component\DependencyInjection\ContainerInterface;
9 9
10/**
11 * Added user_id column on oauth2_clients to prevent users to delete API clients from other users
12 */
10class Version20161024212538 extends AbstractMigration implements ContainerAwareInterface 13class Version20161024212538 extends AbstractMigration implements ContainerAwareInterface
11{ 14{
12 /** 15 /**
@@ -14,6 +17,8 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
14 */ 17 */
15 private $container; 18 private $container;
16 19
20 private $constraintName = 'IDX_user_oauth_client';
21
17 public function setContainer(ContainerInterface $container = null) 22 public function setContainer(ContainerInterface $container = null)
18 { 23 {
19 $this->container = $container; 24 $this->container = $container;
@@ -33,13 +38,14 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
33 38
34 $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.');
35 40
36 $clientsTable->addColumn('user_id', 'integer'); 41 $clientsTable->addColumn('user_id', 'integer', ['notnull' => false]);
37 42
38 $clientsTable->addForeignKeyConstraint( 43 $clientsTable->addForeignKeyConstraint(
39 $this->getTable('user'), 44 $this->getTable('user'),
40 ['user_id'], 45 ['user_id'],
41 ['id'], 46 ['id'],
42 ['onDelete' => 'CASCADE'] 47 ['onDelete' => 'CASCADE'],
48 $this->constraintName
43 ); 49 );
44 } 50 }
45 51
@@ -48,5 +54,14 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
48 */ 54 */
49 public function down(Schema $schema) 55 public function down(Schema $schema)
50 { 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 }
51 } 66 }
52} 67}