towerops/priv/repo/migrations/20260501183033_rename_agent_assignments_unique_index.exs
Graham McIntire 9ca73b949a fix: rename agent_assignments unique index to match device_id column
The original equipment->device rename migration's ALTER INDEX RENAME was a
no-op (the index didn't exist by the legacy name at that point in the
migration sequence on existing databases), leaving the unique index named
agent_assignments_equipment_id_index. The schema's unique_constraint now
expects agent_assignments_device_id_index, causing a constraint violation
to surface as Ecto.ConstraintError instead of a changeset error.
2026-05-01 13:32:03 -05:00

17 lines
407 B
Elixir

defmodule Towerops.Repo.Migrations.RenameAgentAssignmentsUniqueIndex do
use Ecto.Migration
def up do
execute """
ALTER INDEX IF EXISTS agent_assignments_equipment_id_index
RENAME TO agent_assignments_device_id_index
"""
end
def down do
execute """
ALTER INDEX IF EXISTS agent_assignments_device_id_index
RENAME TO agent_assignments_equipment_id_index
"""
end
end