Delete access tokens on user delete (#34036)

Trying to delete a user record from our admin panel throws the following
error:

`update or delete on table "users" violates foreign key constraint
"access_tokens_user_id_fkey" on table "access_tokens"
Detail: Key (id)=(....) is still referenced from table "access_tokens".`

We need to add a cascade delete to the `access_tokens` table.

Release Notes:

- N/A
This commit is contained in:
Joseph T. Lyons 2025-07-08 10:08:17 -04:00 committed by GitHub
parent 3327f90e0f
commit 60e9ab8f93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 54 additions and 1 deletions

View file

@ -26,7 +26,7 @@ CREATE UNIQUE INDEX "index_users_on_github_user_id" ON "users" ("github_user_id"
CREATE TABLE "access_tokens" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"user_id" INTEGER REFERENCES users (id),
"user_id" INTEGER REFERENCES users (id) ON DELETE CASCADE,
"impersonated_user_id" INTEGER REFERENCES users (id),
"hash" VARCHAR(128)
);