mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Created index on visits.date column
This commit is contained in:
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`')
|
->columnName('`date`')
|
||||||
->build();
|
->build();
|
||||||
|
|
||||||
|
$builder->addIndex(['date'], 'IDX_visits_date');
|
||||||
|
|
||||||
$builder->createField('remoteAddr', Types::STRING)
|
$builder->createField('remoteAddr', Types::STRING)
|
||||||
->columnName('remote_addr')
|
->columnName('remote_addr')
|
||||||
->length(Visitor::REMOTE_ADDRESS_MAX_LENGTH)
|
->length(Visitor::REMOTE_ADDRESS_MAX_LENGTH)
|
||||||
|
|||||||
Reference in New Issue
Block a user