fix: prune orphan constructeur links before orientation swap

This commit is contained in:
Matthieu
2025-10-30 12:01:49 +01:00
parent d05b91d7cd
commit e81f71e3e7

View File

@@ -0,0 +1,14 @@
-- Remove constructeur link rows that reference missing parents or constructeur records.
-- This prevents foreign key violations when the orientation of the join tables is normalized.
DELETE FROM "_MachineConstructeurs"
WHERE "A" NOT IN (SELECT "id" FROM "machines")
OR "B" NOT IN (SELECT "id" FROM "constructeurs");
DELETE FROM "_ComposantConstructeurs"
WHERE "A" NOT IN (SELECT "id" FROM "composants")
OR "B" NOT IN (SELECT "id" FROM "constructeurs");
DELETE FROM "_PieceConstructeurs"
WHERE "A" NOT IN (SELECT "id" FROM "pieces")
OR "B" NOT IN (SELECT "id" FROM "constructeurs");