Sooner or later you'll have to change the null constraint in one of your DB relations. How to do it easily in Ecto?
Although I came across many different examples where a raw SQL has been used to perform this type of operation in Ecto, it's actually super easy to do it with modify/3 function.
Let's assume that your migration looks like this:
create table(:blog_posts) do
add :title, :string, null: false
add :intro, :text, null: false
add :body, :text, null: false
add :category_id, references(:blog_categories, on_delete: :delete_all)
end
Top comments (2)
Hi there, we encourage authors to share their entire posts here on DEV, rather than mostly pointing to an external link. Doing so helps ensure that readers don’t have to jump around to too many different pages, and it helps focus the conversation right here in the comments section.
If you choose to do so, you also have the option to add a canonical URL directly to your post.
This post doesn't meet the site rules.