aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2018-06-15 05:25:44 +0000
committerGitHub <noreply@github.com>2018-06-15 05:25:44 +0000
commit7ebd4bdcf7427abcdf3e3938c9b8a3b9bb66bfbb (patch)
treeacc9f383852c9bf33396672135275e0747dd722d /src/Wallabag
parent36054f5dd42413ed5877db8c50fe9f1a3c6167c6 (diff)
parent49b4c875985c7b001af711079662dd3684373229 (diff)
downloadwallabag-7ebd4bdcf7427abcdf3e3938c9b8a3b9bb66bfbb.tar.gz
wallabag-7ebd4bdcf7427abcdf3e3938c9b8a3b9bb66bfbb.tar.zst
wallabag-7ebd4bdcf7427abcdf3e3938c9b8a3b9bb66bfbb.zip
Merge pull request #3538 from wallabag/fix-migrations-dash
Fixed migrations with dash into db names
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php b/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php
new file mode 100644
index 00000000..7aa2409a
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php
@@ -0,0 +1,49 @@
1<?php
2
3namespace Wallabag\CoreBundle\Doctrine;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10abstract class WallabagMigration extends AbstractMigration implements ContainerAwareInterface
11{
12 const UN_ESCAPED_TABLE = true;
13
14 /**
15 * @var ContainerInterface
16 */
17 protected $container;
18
19 // because there are declared as abstract in `AbstractMigration` we need to delarer here too
20 public function up(Schema $schema)
21 {
22 }
23
24 public function down(Schema $schema)
25 {
26 }
27
28 public function setContainer(ContainerInterface $container = null)
29 {
30 $this->container = $container;
31 }
32
33 protected function getTable($tableName, $unEscaped = false)
34 {
35 $table = $this->container->getParameter('database_table_prefix') . $tableName;
36
37 if (self::UN_ESCAPED_TABLE === $unEscaped) {
38 return $table;
39 }
40
41 // escape table name is handled using " on postgresql
42 if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
43 return '"' . $table . '"';
44 }
45
46 // return escaped table
47 return '`' . $table . '`';
48 }
49}