2020-05-03 12:15:26 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace ShlinkMigrations;
|
|
|
|
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
|
|
|
|
final class Version20200503170404 extends AbstractMigration
|
|
|
|
{
|
|
|
|
private const INDEX_NAME = 'IDX_visits_date';
|
|
|
|
|
|
|
|
public function up(Schema $schema): void
|
|
|
|
{
|
|
|
|
$visits = $schema->getTable('visits');
|
|
|
|
$this->skipIf($visits->hasIndex(self::INDEX_NAME));
|
|
|
|
$visits->addIndex(['date'], self::INDEX_NAME);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function down(Schema $schema): void
|
|
|
|
{
|
|
|
|
$visits = $schema->getTable('visits');
|
|
|
|
$this->skipIf(! $visits->hasIndex(self::INDEX_NAME));
|
|
|
|
$visits->dropIndex(self::INDEX_NAME);
|
|
|
|
}
|
2021-03-12 04:52:43 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @fixme Workaround for https://github.com/doctrine/migrations/issues/1104
|
|
|
|
*/
|
|
|
|
public function isTransactional(): bool
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-05-03 12:15:26 -05:00
|
|
|
}
|