mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
load postal codes dynamically
This commit is contained in:
33
Resources/migrations/Version20180703191509.php
Normal file
33
Resources/migrations/Version20180703191509.php
Normal 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');
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user