fix(form-builder): restore FK on form_schemas.default_crowd_type_id (WS-6)
The original session 2.5 migration had to omit this FK due to an SQLite-only "rebuild on FK add" cascade-delete quirk. Now that the test infrastructure has moved to MySQL (Task 1 of this session), the quirk does not apply and the FK is restored to match every other FK in this table. Changes: - New migration `2026_04_28_100000_restore_default_crowd_type_id_foreign_key` adds a FOREIGN KEY (default_crowd_type_id) REFERENCES crowd_types(id) ON DELETE SET NULL. Deleting a CrowdType nulls the column on dependent schemas instead of cascading the schema delete. - Original migration's comment block rewritten — the SQLite-quirk rationale was demonstrably misleading; replaced with a forward-looking pointer to the FK-restore migration. - PersonProvisioner::resolveCrowdTypeId() docblock updated: the runtime failsafe is now defense in depth alongside the DB-level FK + publish guard, not the sole load-bearing check. New test (`DefaultCrowdTypeForeignKeyTest`) exercises both the ON-DELETE-SET-NULL cascade and the existence of the FK in information_schema.REFERENTIAL_CONSTRAINTS — the second assertion would have been impossible on SQLite, which is exactly the point. Migration step counts in 5 backfill tests bumped +1 because the FK- restore migration sits at the top of the migration stack: - FormFieldBindingMigrationTest: 17→18, 15→16 - ConditionalLogicBackfillTest: 6→7 - FormFieldConfigBackfillAndDropTest: 12→13 - FormFieldOptionsBackfillTest: 2→3 - FormFieldValidationRuleBackfillTest: 15→16 All 1388 tests pass on MySQL (1386 prior + 2 new FK tests). Larastan baseline unchanged. Refs: RFC-WS-6.md v1.1 §3 Q9 addendum, WS-6 session 2.5 deviation #1 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -156,10 +156,11 @@ final readonly class PersonProvisioner
|
||||
* declares its target CrowdType explicitly via `default_crowd_type_id`.
|
||||
*
|
||||
* RFC-WS-6 v1.1 §3 Q9 addendum (was: silent oldest() fallback in
|
||||
* session 2). The RequiresDefaultCrowdType publish guard prevents
|
||||
* misconfigured event_registration schemas from publishing; this
|
||||
* runtime throw is a failsafe for live-table edits between publish
|
||||
* and apply.
|
||||
* session 2). Defense in depth: the FK on form_schemas (added in
|
||||
* session 2.6 after the SQLite → MySQL test switch) gives DB-level
|
||||
* referential integrity; the RequiresDefaultCrowdType publish guard
|
||||
* blocks publish when null; this runtime throw is the failsafe for
|
||||
* live-table edits between publish and apply.
|
||||
*
|
||||
* @throws PersonProvisioningException
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user