]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php
Fixed migrations with dash into db name
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Doctrine / WallabagMigration.php
diff --git a/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php b/src/Wallabag/CoreBundle/Doctrine/WallabagMigration.php
new file mode 100644 (file)
index 0000000..eb5ae40
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+
+namespace Wallabag\CoreBundle\Doctrine;
+
+use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Schema\Schema;
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+abstract class WallabagMigration extends AbstractMigration implements ContainerAwareInterface
+{
+    /**
+     * @var ContainerInterface
+     */
+    protected $container;
+
+    // because there are declared as abstract in `AbstractMigration` we need to delarer here too
+    public function up(Schema $schema)
+    {
+    }
+
+    public function down(Schema $schema)
+    {
+    }
+
+    public function setContainer(ContainerInterface $container = null)
+    {
+        $this->container = $container;
+    }
+
+    protected function getTable($tableName)
+    {
+        $table = $this->container->getParameter('database_table_prefix') . $tableName;
+
+        // escape table name is handled using " on postgresql
+        if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
+            return '"' . $table . '"';
+        }
+
+        // return escaped table
+        return '`' . $table . '`';
+    }
+}