aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/DoctrineMigrations/Version20161001072726.php8
-rw-r--r--src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php8
2 files changed, 11 insertions, 5 deletions
diff --git a/app/DoctrineMigrations/Version20161001072726.php b/app/DoctrineMigrations/Version20161001072726.php
index bb7e6968..4e19a54a 100644
--- a/app/DoctrineMigrations/Version20161001072726.php
+++ b/app/DoctrineMigrations/Version20161001072726.php
@@ -24,7 +24,7 @@ class Version20161001072726 extends WallabagMigration
24 $query = $this->connection->query(" 24 $query = $this->connection->query("
25 SELECT CONSTRAINT_NAME 25 SELECT CONSTRAINT_NAME
26 FROM information_schema.key_column_usage 26 FROM information_schema.key_column_usage
27 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_%'
28 AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'" 28 AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'"
29 ); 29 );
30 $query->execute(); 30 $query->execute();
@@ -42,7 +42,7 @@ class Version20161001072726 extends WallabagMigration
42 FROM pg_constraint c 42 FROM pg_constraint c
43 JOIN pg_namespace n ON n.oid = c.connamespace 43 JOIN pg_namespace n ON n.oid = c.connamespace
44 WHERE contype = 'f' 44 WHERE contype = 'f'
45 AND conrelid::regclass::text = '" . $this->getTable('entry_tag') . "' 45 AND conrelid::regclass::text = '" . $this->getTable('entry_tag', WallabagMigration::UN_ESCAPED_TABLE) . "'
46 AND n.nspname = 'public';" 46 AND n.nspname = 'public';"
47 ); 47 );
48 $query->execute(); 48 $query->execute();
@@ -63,7 +63,7 @@ class Version20161001072726 extends WallabagMigration
63 $query = $this->connection->query(" 63 $query = $this->connection->query("
64 SELECT CONSTRAINT_NAME 64 SELECT CONSTRAINT_NAME
65 FROM information_schema.key_column_usage 65 FROM information_schema.key_column_usage
66 WHERE TABLE_NAME = '" . $this->getTable('annotation') . "' 66 WHERE TABLE_NAME = '" . $this->getTable('annotation', WallabagMigration::UN_ESCAPED_TABLE) . "'
67 AND CONSTRAINT_NAME LIKE 'FK_%' 67 AND CONSTRAINT_NAME LIKE 'FK_%'
68 AND COLUMN_NAME = 'entry_id' 68 AND COLUMN_NAME = 'entry_id'
69 AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'" 69 AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'"
@@ -83,7 +83,7 @@ class Version20161001072726 extends WallabagMigration
83 FROM pg_constraint c 83 FROM pg_constraint c
84 JOIN pg_namespace n ON n.oid = c.connamespace 84 JOIN pg_namespace n ON n.oid = c.connamespace
85 WHERE contype = 'f' 85 WHERE contype = 'f'
86 AND conrelid::regclass::text = '" . $this->getTable('annotation') . "' 86 AND conrelid::regclass::text = '" . $this->getTable('annotation', WallabagMigration::UN_ESCAPED_TABLE) . "'
87 AND n.nspname = 'public' 87 AND n.nspname = 'public'
88 AND pg_get_constraintdef(c.oid) LIKE '%entry_id%';" 88 AND pg_get_constraintdef(c.oid) LIKE '%entry_id%';"
89 ); 89 );
diff --git a/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php b/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php
index eb5ae407..7aa2409a 100644
--- a/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php
+++ b/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php
@@ -9,6 +9,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
9 9
10abstract class WallabagMigration extends AbstractMigration implements ContainerAwareInterface 10abstract class WallabagMigration extends AbstractMigration implements ContainerAwareInterface
11{ 11{
12 const UN_ESCAPED_TABLE = true;
13
12 /** 14 /**
13 * @var ContainerInterface 15 * @var ContainerInterface
14 */ 16 */
@@ -28,10 +30,14 @@ abstract class WallabagMigration extends AbstractMigration implements ContainerA
28 $this->container = $container; 30 $this->container = $container;
29 } 31 }
30 32
31 protected function getTable($tableName) 33 protected function getTable($tableName, $unEscaped = false)
32 { 34 {
33 $table = $this->container->getParameter('database_table_prefix') . $tableName; 35 $table = $this->container->getParameter('database_table_prefix') . $tableName;
34 36
37 if (self::UN_ESCAPED_TABLE === $unEscaped) {
38 return $table;
39 }
40
35 // escape table name is handled using " on postgresql 41 // escape table name is handled using " on postgresql
36 if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) { 42 if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
37 return '"' . $table . '"'; 43 return '"' . $table . '"';