wallabag/src/Doctrine/WallabagMigration.php

61 lines
1.6 KiB
PHP
Raw Normal View History

<?php
namespace Wallabag\CoreBundle\Doctrine;
2023-08-05 17:35:09 +00:00
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Schema\Schema;
2018-10-24 19:02:35 +00:00
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class WallabagMigration extends AbstractMigration implements ContainerAwareInterface
{
2022-12-13 09:26:51 +00:00
public const UN_ESCAPED_TABLE = true;
/**
* @var ContainerInterface
*/
protected $container;
// because there are declared as abstract in `AbstractMigration` we need to delarer here too
public function up(Schema $schema): void
{
}
public function down(Schema $schema): void
{
}
2024-02-19 08:31:30 +00:00
public function setContainer(?ContainerInterface $container = null)
{
$this->container = $container;
}
/**
* @todo remove when upgrading DoctrineMigration (only needed for PHP 8)
*
* @see https://github.com/doctrine/DoctrineMigrationsBundle/issues/393
*/
public function isTransactional(): bool
{
return false;
}
protected function getTable($tableName, $unEscaped = false)
{
$table = $this->container->getParameter('database_table_prefix') . $tableName;
if (self::UN_ESCAPED_TABLE === $unEscaped) {
return $table;
}
// escape table name is handled using " on postgresql
2023-08-05 17:35:09 +00:00
if ($this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform) {
return '"' . $table . '"';
}
// return escaped table
return '`' . $table . '`';
}
}