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.
17 lines
407 B
Elixir
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
|