diff --git a/database/migrations/2026_11_01_120000_keep_the_author_of_commits_until_deleted_in_code.php b/database/migrations/2026_11_01_120000_keep_the_author_of_commits_until_deleted_in_code.php new file mode 100644 index 000000000..e332567a2 --- /dev/null +++ b/database/migrations/2026_11_01_120000_keep_the_author_of_commits_until_deleted_in_code.php @@ -0,0 +1,28 @@ + Organization::factory()->create(['handle' => 'Laravel']))->toThrow(UniqueConstraintViolationException::class); }); + +it('never deletes a profile its commits still point to, which the deletion clears in code first', function (): void { + $profile = Profile::factory()->create(); + Commit::factory()->create(['author_id' => $profile->id]); + + expect(fn () => $profile->delete())->toThrow(QueryException::class, 'commits_author_id_foreign'); +});