yesodweb / persistent

Persistence interface for Haskell allowing multiple storage methods.
MIT License
467 stars 297 forks source link

What happened with mkDeleteCascade #1523

Closed schoettl closed 1 year ago

schoettl commented 1 year ago

Hi there,

Just wanted to upgrade to a new stack resolver but I can't figure out where mkDeleteCascade has gone?

It appears to have vanished from persistent-template 2.9.1 to 2.12.0 (absorbed into persistent as per changelog – but I can't find it here).

I used it in my Yesod project:

share [mkPersist sqlSettings, mkDeleteCascade sqlSettings, mkMigrate "migrateAll"]
    $(persistFileWith lowerCaseSettings "config/models")

Is it save to just remove it here? At least it compiles then but I'm not sure if I understand the implications.

parsonsmatt commented 1 year ago

If you remove mkDeleteCascade and nothing happens, then you weren't using the feature at all, and everything is Cool and Good.

The DeleteCascade functionality would create a set of functions that would call delete on all dependencies of a record, and then finally the record itself. This was slow and error prone. We have built in cascade behavior into the QuasiQuoter syntax, so you can now automatically specify the cascade behavior and have SQL do this for you. This is faster and less likely to have issues.

parsonsmatt commented 1 year ago

The relevant PR is here: https://github.com/yesodweb/persistent/pull/1386

and the specific version this was removed in was 2.14

schoettl commented 1 year ago

Great, thanks a lot for the clarification!