Re-add index migration after truncating packets table

The packets table has been truncated so index creation will be fast.
This migration adds indexes for callsign search performance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Graham McIntire 2025-10-25 16:42:39 -05:00
parent 0b9ead4768
commit a22f5ff547
No known key found for this signature in database

View file

@ -0,0 +1,22 @@
defmodule Aprsme.Repo.Migrations.AddCallsignSearchIndexes do
use Ecto.Migration
@disable_ddl_transaction true
def change do
# Add index on sender for pattern matching searches
# Using text_pattern_ops for LIKE/ILIKE queries via raw SQL
execute(
"CREATE INDEX CONCURRENTLY IF NOT EXISTS packets_sender_pattern_idx ON packets (sender text_pattern_ops)",
"DROP INDEX IF EXISTS packets_sender_pattern_idx"
)
# Add index on base_callsign for pattern matching
execute(
"CREATE INDEX CONCURRENTLY IF NOT EXISTS packets_base_callsign_pattern_idx ON packets (base_callsign text_pattern_ops)",
"DROP INDEX IF EXISTS packets_base_callsign_pattern_idx"
)
# Add composite index for sender + received_at for efficient sorting
create_if_not_exists index(:packets, [:sender, :received_at], name: :packets_sender_received_at_idx)
end
end