Documentation Index
Fetch the complete documentation index at: https://planetscale.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
What this error means
FOREIGN_KEYS_CIRCULAR_DEPENDENCY means foreign key relationships form a cycle. This can be a self-referencing table or a group of tables that reference each other in a loop.
Why PlanetScale rejects it
Foreign key cycles can make schema dependency ordering ambiguous. They can also produce unsupported cascaded behavior, especially when all participating constraints useCASCADE or SET NULL actions.
How to fix it
Break the cycle where possible:- Remove one database-enforced foreign key constraint and enforce that relationship in application code.
- Replace cascading actions with explicit application workflows.
- Split schema changes so parent tables and child constraints are introduced in a predictable order.
- For self-references, check whether the constraint is necessary or whether application validation is enough.

