Make the foreig key from last login table be ON DELETE CASCADE
authorMagnus Hagander <magnus@hagander.net>
Sun, 17 Dec 2023 13:44:51 +0000 (14:44 +0100)
committerMagnus Hagander <magnus@hagander.net>
Sun, 17 Dec 2023 15:06:59 +0000 (16:06 +0100)
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

index 8dba3b9e3add5661ab7637746531969473184e79..bb77c8c12ecf17af4a8794c04ba1d2f2a55ce5cf 100644 (file)
@@ -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,