Two companies, one user each. Every test passed on a composite foreign key with its columns the wrong way round.
A dev.to reader pointed this out under my tenant-key post, and I reproduced it on PostgreSQL 18.3.
FOREIGN KEY (assignee_id, company_id) REFERENCES members (company_id, id) pairs columns by position, and Postgres creates it without a word. With Ann as member 1 of company 1 and Bob as member 2 of company 2, every id equals its company id, so the swapped key accepts every fixture.
Schemity, the desktop database design software I build, lints for it: Foreign key columns are paired crosswise.
Then Acme adds Cy, member 3, and assigning Cy an Acme task fails: Key (assignee_id, company_id)=(3, 1) is not present.
What schema lint checks: https://schemity.com/doc/schema-lint/

DEV CommunityDEV CommunityA space to discuss and keep up software development and manage your software career
2 other commits about this linkcommit 5e3e399