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
BLOB_IN_UNIQUE_KEY means a primary key includes a BLOB or TEXT column.
A common error message is:
table "documents" contains BLOB or TEXT column "body" in the primary key.
Why PlanetScale rejects it
PlanetScale needs a stable and efficient unique row identity for online schema changes. BLOB and TEXT columns are not accepted for that row identity because they can be large and are typically indexed through prefixes rather than complete values.
How to fix it
Use a surrogate primary key or a bounded column type that can be indexed fully.
Invalid:
CREATE TABLE documents (
body text NOT NULL,
PRIMARY KEY (body(255))
);
Recommended:
CREATE TABLE documents (
id bigint unsigned NOT NULL,
body text NOT NULL,
PRIMARY KEY (id)
);
If the text value must be unique, consider adding a generated or application-managed hash column with a unique key after evaluating collision risk.
CREATE TABLE documents (
id bigint unsigned NOT NULL,
body text NOT NULL,
body_sha256 binary(32) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY documents_body_sha256_idx (body_sha256)
);
Need help?
Get help from the PlanetScale Support team, or join our Discord community to see how others are using PlanetScale.