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.
This commit is contained in:
Graham McIntire 2026-05-01 13:32:03 -05:00
parent 6a98787cfa
commit 9ca73b949a

View file

@ -0,0 +1,17 @@
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