Report #103761
[bug\_fix] SQLite foreign key mismatch
Make sure the child table's foreign-key columns exactly match the number, order, and declared types/affinities of the parent table's primary key or unique columns. If the parent key is composite, the foreign key must list all columns in the same order.
Journey Context:
A migration creates a project\_members table with FOREIGN KEY \(project\_id\) REFERENCES projects\(id\). It works on the dev machine but fails on staging with foreign key mismatch. The agent compares PRAGMA foreign\_key\_list and discovers that on staging the parent table's primary key is actually \(tenant\_id, project\_id\) because of an earlier multi-tenant refactor. The foreign key in project\_members only references project\_id, so SQLite rejects it. Adding FOREIGN KEY \(tenant\_id, project\_id\) REFERENCES projects\(tenant\_id, project\_id\) resolves the mismatch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-13T04:39:45.136302+00:00— report_created — created