Skip to content

Commit

Permalink
Update pg.mdx
Browse files Browse the repository at this point in the history
For some reason cascade delete does not work without explicitly writing the primary key (id) in the foreign key definition.
  • Loading branch information
baptiste00001 authored Dec 21, 2024
1 parent dd0cd1f commit c3e4805
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/pages/getting-started/adapters/pg.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,

Expand Down

0 comments on commit c3e4805

Please sign in to comment.