PlanetScale Foreign Key Constraints Not Working

Share
Workaround available Web, CLI, Vitess (MySQL), Postgres Updated November 13, 2026Based on 2 user reportsHow we research

Quick answer

Foreign keys must be enabled in database settings, and circular or unresolved references need to be split across deploy requests.

Most likely fix: Enable foreign key constraints

How to fix it

Try these in order — the most common fix is first.

  1. 1. Enable foreign key constraints

    1. Open your database > Settings
    2. Turn on foreign key constraints support
    3. Retry the deploy request
    Did this fix it?
  2. 2. Split the change

    1. Deploy parent table changes first
    2. Add child constraints in a later deploy request
    Did this fix it?
  3. 3. Break circular references

    1. Drop one of the circular constraints
    2. Keep a plain index on the column and enforce the rule in the app
    Did this fix it?

Symptoms

Schema changes fail with FOREIGN_KEYS_CIRCULAR_DEPENDENCY or FOREIGN_KEYS_UNRESOLVED, or constraints are rejected.

Why it happens

  • Foreign key support not turned on
  • Circular dependencies between tables
  • Parent and child tables changed in the same deploy request

This guide also covers

  • planetscale foreign keys
  • planetscale foreign key constraint error

Still not working?

If PlanetScale keeps failing, you're not alone. See every PlanetScale problem users report or the alternatives people switch to.

Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.

Talk to us
Fixed it? Share this guide

Other PlanetScale errors

All 11 PlanetScale errors and fixes →