mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Created index on visits.date column
This commit is contained in:
parent
74ad3553cb
commit
867659ea25
2 changed files with 29 additions and 0 deletions
27
data/migrations/Version20200503170404.php
Normal file
27
data/migrations/Version20200503170404.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
|
@ -32,6 +32,8 @@ return static function (ClassMetadata $metadata, array $emConfig): void {
|
|||
->columnName('`date`')
|
||||
->build();
|
||||
|
||||
$builder->addIndex(['date'], 'IDX_visits_date');
|
||||
|
||||
$builder->createField('remoteAddr', Types::STRING)
|
||||
->columnName('remote_addr')
|
||||
->length(Visitor::REMOTE_ADDRESS_MAX_LENGTH)
|
||||
|
|
Loading…
Add table
Reference in a new issue