aprs.me/priv/repo/migrations/20250715155632_remove_duplicate_received_at_indexes.exs
Graham McIntire e97d1d6e33
Fix duplicate indexes and missing socket assigns
- Remove duplicate received_at indexes (packets_received_at_asc_idx and packets_recent_hour_idx)
  that were consuming 423 MB, keeping only packets_received_at_idx
- Fix KeyError by initializing missing :all_packets and :visible_packets in socket assigns
- All tests now pass successfully

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-15 11:01:27 -05:00

23 lines
926 B
Elixir

defmodule Aprsme.Repo.Migrations.RemoveDuplicateReceivedAtIndexes do
use Ecto.Migration
def up do
# Remove duplicate indexes on received_at column
# Keep only packets_received_at_idx which is the most general purpose
drop_if_exists index(:packets, [:received_at], name: :packets_received_at_asc_idx)
drop_if_exists index(:packets, [:received_at], name: :packets_recent_hour_idx)
end
def down do
# Recreate the removed indexes
create_if_not_exists index(:packets, [:received_at],
name: :packets_received_at_asc_idx,
comment: "Index for cleanup worker queries (ascending for old packets)"
)
create_if_not_exists index(:packets, [:received_at],
name: :packets_recent_hour_idx,
comment: "Index for recent packet queries"
)
end
end