Skip to main content

What this error means

FOREIGN_KEYS_DISALLOWED means the schema contains a FOREIGN KEY constraint, but the database is not configured to allow foreign key constraints. A common error message is:
The error may also include the local column names used by the foreign key.

Why PlanetScale rejects it

PlanetScale databases can run with foreign key constraints disabled or managed. When constraints are disabled, Vitess rejects DDL that creates them so the database does not enter a mixed or unsupported foreign key mode.

How to fix it

Choose one of these approaches:
  • Enable foreign key constraint support for the database if your workload needs database-enforced referential integrity and the database meets the prerequisites.
  • Remove the CONSTRAINT ... FOREIGN KEY clause and keep ordinary indexes for query performance.
  • Enforce referential integrity in application code or background jobs instead of with database constraints.
Invalid when foreign keys are disabled:
Constraint-free version:

Need help?

Get help from the PlanetScale Support team, or join our Discord community to see how others are using PlanetScale.