mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-21 16:38:37 -06:00
Adds index on the valid_until column of the short_urls table to improve the performance of the DeleteExpiredShortUrlsCommand
This commit is contained in:
parent
59fa088975
commit
814c9f06d9
35
module/Core/migrations/Version20240425194703.php
Normal file
35
module/Core/migrations/Version20240425194703.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkMigrations;
|
||||
|
||||
use Doctrine\DBAL\Platforms\MySQLPlatform;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20240425194703 extends AbstractMigration
|
||||
{
|
||||
private const INDEX_NAME = 'IDX_links_expiry_date';
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$visits = $schema->getTable('short_urls');
|
||||
$this->skipIf($visits->hasIndex(self::INDEX_NAME));
|
||||
|
||||
$visits->addIndex(['valid_until'], self::INDEX_NAME);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$visits = $schema->getTable('short_urls');
|
||||
$this->skipIf(!$visits->hasIndex(self::INDEX_NAME));
|
||||
|
||||
$visits->dropIndex(self::INDEX_NAME);
|
||||
}
|
||||
|
||||
public function isTransactional(): bool
|
||||
{
|
||||
return ! ($this->connection->getDatabasePlatform() instanceof MySQLPlatform);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user