From 115586cd2f6266619cbe07b446d37ddf3a9d554f Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sun, 17 Dec 2023 14:44:51 +0100 Subject: [PATCH] Make the foreig key from last login table be ON DELETE CASCADE Since this one is not managed inside Django, it doesn't know what to do with it when deleting, so just make postgres handle it. --- pgweb/account/migrations/0004_cauth_last_login.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgweb/account/migrations/0004_cauth_last_login.py b/pgweb/account/migrations/0004_cauth_last_login.py index 8dba3b9e..bb77c8c1 100644 --- a/pgweb/account/migrations/0004_cauth_last_login.py +++ b/pgweb/account/migrations/0004_cauth_last_login.py @@ -13,7 +13,7 @@ class Migration(migrations.Migration): operations = [ migrations.RunSQL("""CREATE TABLE account_communityauthlastlogin ( - user_id int NOT NULL REFERENCES auth_user(id) DEFERRABLE INITIALLY DEFERRED, + user_id int NOT NULL REFERENCES auth_user(id) DEFERRABLE INITIALLY DEFERRED ON DELETE CASCADE, site_id int NOT NULL REFERENCES account_communityauthsite (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, lastlogin timestamptz NOT NULL, logincount bigint NOT NULL, -- 2.39.5