defmodule Microwaveprop.Repo.Migrations.AddTrainingPerformanceIndexes do use Ecto.Migration def change do # QSO training data queries filter on timestamp + distance + positions create_if_not_exists index(:qsos, [:qso_timestamp]) create_if_not_exists index(:qsos, [:band]) create_if_not_exists index(:qsos, [:distance_km]) # Callsign search: trigram index for ILIKE on station1/station2 execute( "CREATE EXTENSION IF NOT EXISTS pg_trgm", "SELECT 1" ) execute( "CREATE INDEX IF NOT EXISTS qsos_station1_trgm_index ON qsos USING gin (station1 gin_trgm_ops)", "DROP INDEX IF EXISTS qsos_station1_trgm_index" ) execute( "CREATE INDEX IF NOT EXISTS qsos_station2_trgm_index ON qsos USING gin (station2 gin_trgm_ops)", "DROP INDEX IF EXISTS qsos_station2_trgm_index" ) end end