djezzzl/database_consistency

ForeignKeyCascadeChecker default mapping

pyromaniac opened this issue · 3 comments

Hey @djezzzl I believe that the mapping here

restrict_with_exception: :restrict,
restrict_with_error: :restrict
is not entirely correct.
Accordingly to https://stackoverflow.com/questions/60043008/when-to-use-nothing-or-restrict-for-on-delete-with-ecto the default NO ACTION value also raises an error, it is just deferred. But for this purpose it would be perfect to have something like:

      OPTION_TO_CASCADE = {
        delete: :cascade,
        delete_all: :cascade,
        nullify: :nullify,
        restrict_with_exception: [nil, :restrict],
        restrict_with_error: [nil, :restrict]
      }.freeze

WDYT?

Hi @pyromaniac,

Yes, it seems you're correct. Thank you for sharing this! Would you like to make a PR for that?

I'm sorry it took me long to look at the issue.

Yes, will do soon

Thank you! I would be happy to merge and release immediately.