aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20161001072726.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/DoctrineMigrations/Version20161001072726.php')
-rw-r--r--app/DoctrineMigrations/Version20161001072726.php29
1 files changed, 6 insertions, 23 deletions
diff --git a/app/DoctrineMigrations/Version20161001072726.php b/app/DoctrineMigrations/Version20161001072726.php
index f9d088a3..4e19a54a 100644
--- a/app/DoctrineMigrations/Version20161001072726.php
+++ b/app/DoctrineMigrations/Version20161001072726.php
@@ -2,28 +2,16 @@
2 2
3namespace Application\Migrations; 3namespace Application\Migrations;
4 4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Migrations\SkipMigrationException; 5use Doctrine\DBAL\Migrations\SkipMigrationException;
7use Doctrine\DBAL\Schema\Schema; 6use Doctrine\DBAL\Schema\Schema;
8use Symfony\Component\DependencyInjection\ContainerAwareInterface; 7use Wallabag\CoreBundle\Doctrine\WallabagMigration;
9use Symfony\Component\DependencyInjection\ContainerInterface;
10 8
11/** 9/**
12 * Added pocket_consumer_key field on wallabag_config. 10 * Added pocket_consumer_key field on wallabag_config.
13 */ 11 */
14class Version20161001072726 extends AbstractMigration implements ContainerAwareInterface 12class Version20161001072726 extends WallabagMigration
15{ 13{
16 /** 14 /**
17 * @var ContainerInterface
18 */
19 private $container;
20
21 public function setContainer(ContainerInterface $container = null)
22 {
23 $this->container = $container;
24 }
25
26 /**
27 * @param Schema $schema 15 * @param Schema $schema
28 */ 16 */
29 public function up(Schema $schema) 17 public function up(Schema $schema)
@@ -36,7 +24,7 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
36 $query = $this->connection->query(" 24 $query = $this->connection->query("
37 SELECT CONSTRAINT_NAME 25 SELECT CONSTRAINT_NAME
38 FROM information_schema.key_column_usage 26 FROM information_schema.key_column_usage
39 WHERE TABLE_NAME = '" . $this->getTable('entry_tag') . "' AND CONSTRAINT_NAME LIKE 'FK_%' 27 WHERE TABLE_NAME = '" . $this->getTable('entry_tag', WallabagMigration::UN_ESCAPED_TABLE) . "' AND CONSTRAINT_NAME LIKE 'FK_%'
40 AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'" 28 AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'"
41 ); 29 );
42 $query->execute(); 30 $query->execute();
@@ -54,7 +42,7 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
54 FROM pg_constraint c 42 FROM pg_constraint c
55 JOIN pg_namespace n ON n.oid = c.connamespace 43 JOIN pg_namespace n ON n.oid = c.connamespace
56 WHERE contype = 'f' 44 WHERE contype = 'f'
57 AND conrelid::regclass::text = '" . $this->getTable('entry_tag') . "' 45 AND conrelid::regclass::text = '" . $this->getTable('entry_tag', WallabagMigration::UN_ESCAPED_TABLE) . "'
58 AND n.nspname = 'public';" 46 AND n.nspname = 'public';"
59 ); 47 );
60 $query->execute(); 48 $query->execute();
@@ -75,7 +63,7 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
75 $query = $this->connection->query(" 63 $query = $this->connection->query("
76 SELECT CONSTRAINT_NAME 64 SELECT CONSTRAINT_NAME
77 FROM information_schema.key_column_usage 65 FROM information_schema.key_column_usage
78 WHERE TABLE_NAME = '" . $this->getTable('annotation') . "' 66 WHERE TABLE_NAME = '" . $this->getTable('annotation', WallabagMigration::UN_ESCAPED_TABLE) . "'
79 AND CONSTRAINT_NAME LIKE 'FK_%' 67 AND CONSTRAINT_NAME LIKE 'FK_%'
80 AND COLUMN_NAME = 'entry_id' 68 AND COLUMN_NAME = 'entry_id'
81 AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'" 69 AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'"
@@ -95,7 +83,7 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
95 FROM pg_constraint c 83 FROM pg_constraint c
96 JOIN pg_namespace n ON n.oid = c.connamespace 84 JOIN pg_namespace n ON n.oid = c.connamespace
97 WHERE contype = 'f' 85 WHERE contype = 'f'
98 AND conrelid::regclass::text = '" . $this->getTable('annotation') . "' 86 AND conrelid::regclass::text = '" . $this->getTable('annotation', WallabagMigration::UN_ESCAPED_TABLE) . "'
99 AND n.nspname = 'public' 87 AND n.nspname = 'public'
100 AND pg_get_constraintdef(c.oid) LIKE '%entry_id%';" 88 AND pg_get_constraintdef(c.oid) LIKE '%entry_id%';"
101 ); 89 );
@@ -117,9 +105,4 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
117 { 105 {
118 throw new SkipMigrationException('Too complex ...'); 106 throw new SkipMigrationException('Too complex ...');
119 } 107 }
120
121 private function getTable($tableName)
122 {
123 return $this->container->getParameter('database_table_prefix') . $tableName;
124 }
125} 108}