load postal codes dynamically

This commit is contained in:
2018-07-05 13:02:21 +02:00
parent 86a814cfb5
commit 26a4d80ce6
16 changed files with 368 additions and 10 deletions

View File

@@ -0,0 +1,33 @@
<?php declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Add index to postal code
*/
final class Version20180703191509 extends AbstractMigration
{
public function up(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
try {
$this->addSql('CREATE EXTENSION IF NOT EXISTS pg_trgm');
$this->addSql('CREATE INDEX search_name_code ON chill_main_postal_code USING GIN (LOWER(code) gin_trgm_ops, LOWER(label) gin_trgm_ops)');
} catch (\Exception $e) {
$this->skipIf(true, "Could not create extension pg_trgm");
}
}
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 search_name_code');
}
}