Modify a references-column in an ecto migration

The normal way of putting a single change in a change function does not work here, because modifying a column like this cannot be done by Ecto. So we need to drop an existing index first and then modify the column with the references function which will re-create that same index.

def up do
  drop(constraint(:address, "address_person_id_fkey"))

  alter table(:address) do
    modify(:person_id, references(:person, on_delete: :nothing), null: false
  end
end

def down do
  drop(constraint(:address, "address_person_id_fkey"))

  alter table(:address) do
    modify(:person_id, references(:person, on_delete: :delete_all), null: false
  end
end