fix(timetable): null-on-delete advance_submissions per RFC §5.4 retention
advance_submissions.advance_section_id FK changed from cascadeOnDelete
to nullOnDelete; column made nullable. Aligns implementation with
RFC v0.2 §5.4 audit-immutability ("submissions remain for retention
compliance") — when ArtistEngagementObserver::deleted hard-deletes a
section, its submissions persist as orphans rather than disappearing.
Migration edited in place (branch unpushed, dev-only). Observer
docblock + test assertion updated to match. Removed pre-existing
follow-up comment that documented the deviation.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -81,7 +81,7 @@ final class ArtistEngagementObserverTest extends TestCase
|
||||
'type' => 'production',
|
||||
]);
|
||||
|
||||
AdvanceSubmission::create([
|
||||
$submission = AdvanceSubmission::create([
|
||||
'advance_section_id' => $section->id,
|
||||
'submitted_by_name' => 'TM',
|
||||
'submitted_by_email' => 'tm@example.test',
|
||||
@@ -90,6 +90,8 @@ final class ArtistEngagementObserverTest extends TestCase
|
||||
'data' => [],
|
||||
]);
|
||||
|
||||
$submissionCountBefore = AdvanceSubmission::withoutGlobalScope(OrganisationScope::class)->count();
|
||||
|
||||
$eng->delete();
|
||||
|
||||
// Performance is soft-deleted (trashed, not removed).
|
||||
@@ -99,11 +101,15 @@ final class ArtistEngagementObserverTest extends TestCase
|
||||
// AdvanceSection is hard-deleted.
|
||||
$this->assertNull(AdvanceSection::withoutGlobalScope(OrganisationScope::class)->find($section->id));
|
||||
|
||||
// Note: `advance_submissions.advance_section_id` currently uses
|
||||
// `cascadeOnDelete()`, so submissions are removed with their section.
|
||||
// RFC v0.2 §5.4 calls submissions "audit-immutable" — interpreted
|
||||
// here as "no application code mutates them post-creation". A
|
||||
// future migration may switch the FK to nullOnDelete to preserve
|
||||
// rows past section hard-delete; out of Session 1 scope.
|
||||
// AdvanceSubmission survives as audit-orphan per RFC §5.4: row
|
||||
// preserved, advance_section_id nulled by FK ON DELETE SET NULL.
|
||||
$this->assertSame(
|
||||
$submissionCountBefore,
|
||||
AdvanceSubmission::withoutGlobalScope(OrganisationScope::class)->count(),
|
||||
'advance_submissions must persist for retention compliance'
|
||||
);
|
||||
$orphan = AdvanceSubmission::withoutGlobalScope(OrganisationScope::class)->find($submission->id);
|
||||
$this->assertNotNull($orphan);
|
||||
$this->assertNull($orphan->advance_section_id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user