2018-06-14 11:43:09 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Wallabag\CoreBundle\Doctrine;
|
|
|
|
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
2018-10-24 19:02:35 +00:00
|
|
|
use Doctrine\Migrations\AbstractMigration;
|
2018-06-14 11:43:09 +00:00
|
|
|
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;
|
2018-06-14 12:15:07 +00:00
|
|
|
|
2018-06-14 11:43:09 +00:00
|
|
|
/**
|
|
|
|
* @var ContainerInterface
|
|
|
|
*/
|
|
|
|
protected $container;
|
|
|
|
|
|
|
|
// because there are declared as abstract in `AbstractMigration` we need to delarer here too
|
2022-12-14 13:36:29 +00:00
|
|
|
public function up(Schema $schema): void
|
2018-06-14 11:43:09 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-12-14 13:36:29 +00:00
|
|
|
public function down(Schema $schema): void
|
2018-06-14 11:43:09 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setContainer(ContainerInterface $container = null)
|
|
|
|
{
|
|
|
|
$this->container = $container;
|
|
|
|
}
|
|
|
|
|
2022-01-31 08:27:20 +00:00
|
|
|
/**
|
|
|
|
* @todo remove when upgrading DoctrineMigration (only needed for PHP 8)
|
|
|
|
*
|
|
|
|
* @see https://github.com/doctrine/DoctrineMigrationsBundle/issues/393
|
|
|
|
*/
|
|
|
|
public function isTransactional(): bool
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-06-14 12:15:07 +00:00
|
|
|
protected function getTable($tableName, $unEscaped = false)
|
2018-06-14 11:43:09 +00:00
|
|
|
{
|
|
|
|
$table = $this->container->getParameter('database_table_prefix') . $tableName;
|
|
|
|
|
2018-06-14 12:15:07 +00:00
|
|
|
if (self::UN_ESCAPED_TABLE === $unEscaped) {
|
|
|
|
return $table;
|
|
|
|
}
|
|
|
|
|
2018-06-14 11:43:09 +00:00
|
|
|
// escape table name is handled using " on postgresql
|
|
|
|
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
|
|
|
|
return '"' . $table . '"';
|
|
|
|
}
|
|
|
|
|
|
|
|
// return escaped table
|
|
|
|
return '`' . $table . '`';
|
|
|
|
}
|
|
|
|
}
|