From c3e4805db4580b13ab70bddeea04e5aafea15170 Mon Sep 17 00:00:00 2001 From: Baptiste L <54464650+baptiste00001@users.noreply.github.com> Date: Sat, 21 Dec 2024 16:30:27 +0900 Subject: [PATCH] Update pg.mdx For some reason cascade delete does not work without explicitly writing the primary key (id) in the foreign key definition. --- docs/pages/getting-started/adapters/pg.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/pages/getting-started/adapters/pg.mdx b/docs/pages/getting-started/adapters/pg.mdx index cac20aaa4a..a19e8237ec 100644 --- a/docs/pages/getting-started/adapters/pg.mdx +++ b/docs/pages/getting-started/adapters/pg.mdx @@ -216,7 +216,7 @@ CREATE TABLE users CREATE TABLE accounts ( id SERIAL, - "userId" INTEGER NOT NULL REFERENCES users ON DELETE CASCADE, + "userId" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE, type VARCHAR(255) NOT NULL, provider VARCHAR(255) NOT NULL, "providerAccountId" VARCHAR(255) NOT NULL, @@ -234,7 +234,7 @@ CREATE TABLE accounts CREATE TABLE sessions ( id SERIAL, - "userId" INTEGER NOT NULL REFERENCES users ON DELETE CASCADE, + "userId" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE, expires TIMESTAMPTZ NOT NULL, "sessionToken" VARCHAR(255) UNIQUE NOT NULL,