You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is often to have "on_delete: :cascade" on association. In typed_dag, it would be on the edge AR.
This is not mentioned in the README. I wonder whether it is a good practice or not to add "on_delete: :cascade" on edge migration like this:
Admittedly I haven't thought about it before and thus haven't tested it.
I'd assume that having a cascade on the edges is ok.
What is not supported however, is having anything that deletes the edge database records without going through Rails. So a delete on the edge class or an on_delete: :cascade on anything referencing the edges will break the DAG.
Could you please elaborate on deleting edges through Rails ? If I destroy a node in Rails via node.destroy, do I also need to destroy edges manually, e.g. node.descendants.destroy_all, or typed_dag will handle the destruction of edges internally ? Thanks !!
or typed_dag will handle the destruction of edges internally?
Yes I think this is the case. You don't have to run node.descendants.destroy_all
What @ulferts says is that you should always delete through Rails using, for example, node.destroy and not node.delete. node.delete will run a direct SQL DELETE statement and typed_dag callbacks won't be called in this case. So the DAG will break
It is often to have "on_delete: :cascade" on association. In typed_dag, it would be on the edge AR.
This is not mentioned in the README. I wonder whether it is a good practice or not to add "on_delete: :cascade" on edge migration like this:
Thanks !!
The text was updated successfully, but these errors were encountered: