sfDoctrineGuardPlugin is evil (on delete cascade)

It happened once, a while ago and it happened again… We’ve deleted a user on the sf_guard_user table and ALL records from ALL tables with that user’s ID (on created_by / updated_by field), got dropped!

Some wise guy thought it made sense to delete all user’s related entries when you delete the user :S

Heres how to change that weird behaviour. On all your schema models, change the old “Signable: ~”, to:

1
2
3
4
5
6
ActAs:
  Signable:
    created:
      onDelete: set null
    updated:
      onDelete: set null

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>