adding indexes

This commit is contained in:
2018-11-13 21:53:28 +01:00
parent 38c272f89e
commit d1083e97cb
5 changed files with 87 additions and 2 deletions

View File

@@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add index on single_task_place_events
*/
final class Version20181113161925 extends AbstractMigration
{
public function up(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE INDEX transition_task_date ON chill_task.single_task_place_event (task_id, transition, datetime)');
$this->addSql('CREATE INDEX transition_task ON chill_task.single_task_place_event (task_id, transition)');
}
public function down(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP INDEX transition_task_date');
$this->addSql('DROP INDEX transition_task');
}
}

View File

@@ -0,0 +1,28 @@
<?php declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add index on single task
*/
final class Version20181113164108 extends AbstractMigration
{
public function up(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE INDEX by_type ON chill_task.single_task (type)');
$this->addSql('CREATE INDEX by_current_state ON chill_task.single_task USING GIN (current_states)');
}
public function down(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP INDEX by_type');
$this->addSql('DROP INDEX by_current_state');
}
}