Skip to content

Commit

Permalink
Add IF NOT EXISTS conditions on indexes creation (#778)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarchois authored May 17, 2024
1 parent 2dca9c1 commit ac4f4af
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public function getDescription(): string

public function up(Schema $schema): void
{
$this->addSql('CREATE EXTENSION postgis');
$this->addSql('CREATE EXTENSION IF NOT EXISTS postgis');
}

public function down(Schema $schema): void
{
$this->addSql('DROP EXTENSION postgis');
$this->addSql('DROP EXTENSION IF EXISTS postgis');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public function up(Schema $schema): void
$func$;
');

$this->addSql('CREATE INDEX voie_nommee_normalized_nom_minuscule_code_insee_idx ON voie_nommee (f_bdtopo_voie_nommee_normalize_nom_minuscule(nom_minuscule), code_insee);');
$this->addSql('CREATE INDEX route_numerotee_ou_nommee_numero_gestionnaire_idx ON route_numerotee_ou_nommee (numero, gestionnaire);');
$this->addSql('CREATE INDEX IF NOT EXISTS voie_nommee_normalized_nom_minuscule_code_insee_idx ON voie_nommee (f_bdtopo_voie_nommee_normalize_nom_minuscule(nom_minuscule), code_insee);');
$this->addSql('CREATE INDEX IF NOT EXISTS route_numerotee_ou_nommee_numero_gestionnaire_idx ON route_numerotee_ou_nommee (numero, gestionnaire);');
}

public function down(Schema $schema): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getDescription(): string

public function up(Schema $schema): void
{
$this->addSql('CREATE INDEX point_de_repere_route_numero_gestionnaire_cote_idx ON point_de_repere (route, numero, gestionnaire, cote);');
$this->addSql('CREATE INDEX IF NOT EXISTS point_de_repere_route_numero_gestionnaire_cote_idx ON point_de_repere (route, numero, gestionnaire, cote);');
}

public function down(Schema $schema): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function getDescription(): string
public function up(Schema $schema): void
{
$this->addSql("ALTER TABLE voie_nommee ADD COLUMN nom_minuscule_search tsvector GENERATED ALWAYS AS (to_tsvector('french', nom_minuscule)) STORED");
$this->addSql('CREATE INDEX voie_nommee_nom_minuscule_search_idx ON voie_nommee USING GIN(nom_minuscule_search)');
$this->addSql('CREATE INDEX voie_nommee_code_insee_idx ON voie_nommee (code_insee)');
$this->addSql('CREATE INDEX IF NOT EXISTS voie_nommee_nom_minuscule_search_idx ON voie_nommee USING GIN(nom_minuscule_search)');
$this->addSql('CREATE INDEX IF NOT EXISTS voie_nommee_code_insee_idx ON voie_nommee (code_insee)');
}

public function down(Schema $schema): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public function getDescription(): string

public function up(Schema $schema): void
{
$this->addSql('CREATE EXTENSION pg_trgm');
$this->addSql('CREATE EXTENSION IF NOT EXISTS pg_trgm');
}

public function down(Schema $schema): void
{
$this->addSql('DROP EXTENSION pg_trgm');
$this->addSql('DROP EXTENSION IF EXISTS pg_trgm');
}
}

0 comments on commit ac4f4af

Please sign in to comment.