Skip to main content

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

PARTIAL_KEY_IN_UNIQUE_KEY means a primary key uses a prefix length, such as name(10). A common error message is:
table "customers" contains partial index on column "email" in the primary key.

Why PlanetScale rejects it

A prefix index only indexes part of a column value. PlanetScale needs a unique key that can identify the full row during online schema changes. A partial key is not accepted as that identity.

How to fix it

Use a full column in the primary key, add a surrogate primary key, or add a separate full unique key over NOT NULL columns. Invalid:
CREATE TABLE customers (
  email varchar(255) NOT NULL,
  PRIMARY KEY (email(32))
);
Recommended:
CREATE TABLE customers (
  id bigint unsigned NOT NULL,
  email varchar(255) NOT NULL,
  PRIMARY KEY (id),
  UNIQUE KEY customers_email_idx (email)
);
If the full column is too large for your indexing strategy, use a shorter bounded column type or a separate stable identifier.

Need help?

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