MySQL silently ignores inline foreign key definitions (e.g., `customer_id INT REFERENCES customers(customer_id)`), treating them as comments rather than enforcing constraints. This is a documented MySQL behavior: foreign key constraints are only enforced when defined as a separate `FOREIGN KEY` clause. Postgres, by contrast, enforces inline foreign key definitions correctly. This difference can cause silent data integrity violations when migrating schemas from Postgres to MySQL, as invalid records can be inserted without any error. The fix is to always use explicit `FOREIGN KEY` constraint clauses in both databases, and to thoroughly review schema definitions when porting between the two systems.

6m read timeFrom neon.com
Post cover image
Table of contents
A refresher on foreign keysThe subtle difference in defining foreign keys in MySQL and PostgresConclusion
1 Impression