Skip to content

Commit 295b8e7

Browse files
Delete invalid build2update rows before migration (#3395)
The updateid column did not have a foreign-key constraint, so it's possible for records to exist in the build2update table without a corresponding record in the buildupdate table.
1 parent 31cc555 commit 295b8e7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

database/migrations/2026_01_15_143405_drop_build2update_table.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
return new class extends Migration {
66
public function up(): void
77
{
8+
DB::delete('DELETE FROM build2update WHERE NOT EXISTS (SELECT 1 FROM buildupdate WHERE build2update.updateid = buildupdate.id)');
9+
810
DB::statement('ALTER TABLE build ADD COLUMN updateid bigint');
911
DB::statement('ALTER TABLE build ADD FOREIGN KEY (updateid) REFERENCES buildupdate(id) ON DELETE SET NULL');
1012

0 commit comments

Comments
 (0)