Can you modify a column's references/3 options in Ecto?

if you use the :from option, you can use the change without explicit declaring up and down:

def change do
  alter table(:address) do
    modify :person_id, references(:person, on_delete: :nothing),
      from: references(:person, on_delete: :delete_all)
  end
end

docs: Ecto.Migration — Ecto SQL v3.11.1

This command is not reversible unless the :from option is provided. If the :from value is a %Reference{} , the adapter will try to drop the corresponding foreign key constraints before modifying the type.

27 Likes