onDelete cascade, Error: VT10001: foreign key constraints are not allowed

Trying to add onDelete cascade and db push produces this error: foreign key constraints are not allowed
import { relations } from "drizzle-orm";
import { mysqlTable, index, varchar, double } from "drizzle-orm/mysql-core";
import { request } from "./request";

export const requestItem = mysqlTable(
"RequestItem",
{
id: varchar("id", { length: 191 }).primaryKey().notNull(),
requestId: varchar("requestId", { length: 191 })
.notNull()
.references(() => request.id, { onDelete: "cascade" }),
title: varchar("title", { length: 191 }).notNull(),
description: varchar("description", { length: 191 }).notNull(),
estimatedValue: double("estimatedValue", {
precision: 10,
scale: 2,
}),
},
(table) => {
return {
requestIdIdx: index("RequestItem_requestId_idx").on(table.requestId),
};
}
);

export const requestItemRelations = relations(requestItem, ({ one }) => ({
request: one(request, {
fields: [requestItem.requestId],
references: [request.id],
}),
}));
import { relations } from "drizzle-orm";
import { mysqlTable, index, varchar, double } from "drizzle-orm/mysql-core";
import { request } from "./request";

export const requestItem = mysqlTable(
"RequestItem",
{
id: varchar("id", { length: 191 }).primaryKey().notNull(),
requestId: varchar("requestId", { length: 191 })
.notNull()
.references(() => request.id, { onDelete: "cascade" }),
title: varchar("title", { length: 191 }).notNull(),
description: varchar("description", { length: 191 }).notNull(),
estimatedValue: double("estimatedValue", {
precision: 10,
scale: 2,
}),
},
(table) => {
return {
requestIdIdx: index("RequestItem_requestId_idx").on(table.requestId),
};
}
);

export const requestItemRelations = relations(requestItem, ({ one }) => ({
request: one(request, {
fields: [requestItem.requestId],
references: [request.id],
}),
}));
8 Replies
Andrii Sherman
Andrii Sherman17mo ago
Is it Planetscale?
focused_morning
focused_morningOP17mo ago
Hey, Andrew! Yeah its Pscale
Andrii Sherman
Andrii Sherman17mo ago
FK's are not supported by PlanetScale so you can't use it there
focused_morning
focused_morningOP17mo ago
so no onDelete cascade in pscale, is that what you mean?
Andrii Sherman
Andrii Sherman17mo ago
yes
focused_morning
focused_morningOP17mo ago
Thanks for the clarification, also nice work clearing up so many questions in a single go. We appreciate you!
Andrii Sherman
Andrii Sherman17mo ago
spent 4 hours non-stop
focused_morning
focused_morningOP17mo ago
Wow, time for a break.
Want results from more Discord servers?
Add your server