Skip to content

Commit a36f31f

Browse files
committed
Added documentation for cascade delete and SQLite
1 parent 60320b5 commit a36f31f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

doc/setup.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,19 @@ $aclSetup->setUpEntityManager($entityManager, $aclLocator);
6464

6565
These listeners handle different things, like registering your role and user classes, and registering
6666
a listener that will act when new resources/entities are created (to cascade authorizations).
67+
68+
69+
## Cascade delete
70+
71+
To be as efficient as possible, MyCLabs\ACL uses `ON DELETE CASCADE` at database level.
72+
73+
For example, when a role is removed, all of its authorizations will be deleted in cascade by MySQL/SQLite/…
74+
That allows to bypass using Doctrine's "cascade remove" which loads all the entities in memory (there could
75+
be thousands of authorizations).
76+
77+
However this means **your database must support CASCADE operations**. MySQL and PostgreSQL support it,
78+
but SQLite usually [needs a configuration step](http://www.sqlite.org/foreignkeys.html#fk_enable):
79+
80+
```php
81+
$entityManager->getConnection()->executeQuery('PRAGMA foreign_keys = ON');
82+
```

0 commit comments

Comments
 (0)