Delete options and responses together with their poll
Deleting a poll removed its slides with a plain deleteAll and relied on ON DELETE CASCADE for slide options and responses. SQLite does not enforce foreign keys by default, so answers of deleted polls stayed in the database. Cascade through the ORM instead and remove the rows left behind earlier. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8b0e82d806
commit
0a4c9fad09
4 files changed
+71
-1
No files matched your search
@@ -48,7 +48,9 @@ class PollsTable extends Table
|
||||
'foreignKey' => 'poll_id',
|
||||
'sort' => ['Slides.position' => 'ASC', 'Slides.id' => 'ASC'],
|
||||
'dependent' => true,
|
||||
'cascadeCallbacks' => false,
|
||||
// Delete slide by slide so their options and responses go too. Do not rely on
|
||||
// ON DELETE CASCADE: SQLite does not enforce foreign keys by default.
|
||||
'cascadeCallbacks' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user