I have an existing migration Posts
One post has many comments. It is structured as follows.
id
post_name
post_num
comments
[
%{
id
post_num
},
%{
id
post_num
},
]
I would like to add a constraint that checks if the post_num
in Posts
matches the post_num
in comments
, if not it should return an error changeset. I came across Ecto.Changeset.check_constraint
from the docs. I feel this will be more suitable for my scenario here (would appreciate any other better options aswell). I would like to know how to create a migration for this case and what goes into the migration file.