DependentStrategy
: string
in package
Defines cascade behavior when a parent model is destroyed.
Similar to Rails' dependent option for associations.
Table of Contents
Cases
- DeleteAll = 'delete_all'
- Delete all associated records with a single SQL DELETE query.
- Destroy = 'destroy'
- Call destroy() on each associated record.
- Nullify = 'nullify'
- Set the foreign key to NULL on associated records.
- Restrict = 'restrict'
- Raise an exception if any associated records exist.
Cases
Destroy
Call destroy() on each associated record.
This triggers any callbacks and cascades further.
DeleteAll
Delete all associated records with a single SQL DELETE query.
More efficient than destroy but skips callbacks.
Nullify
Set the foreign key to NULL on associated records.
Requires the foreign key column to allow NULL.
Restrict
Raise an exception if any associated records exist.
Prevents deletion when associations are present.