Skip to content

Commit

Permalink
Show how to modify the cascade of a foreign key (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanl committed Jul 14, 2023
1 parent ddc72dc commit 2b1f9dc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/ecto/migration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,12 @@ defmodule Ecto.Migration do
modify :title, :text, null: false, from: {:string, null: true}
end
# Modify the :on_delete option of an existing foreign key
alter table("comments") do
modify :post_id, references(:posts, on_delete: :delete_all),
from: references(:posts, on_delete: :nothing)
end
## Options
* `:null` - determines whether the column accepts null values. If this option is
Expand Down

0 comments on commit 2b1f9dc

Please sign in to comment.