Skip to content

Commit 8e5abe6

Browse files
committed
Minor postgresql migration fixes
- we could leave "empty" (i.e. all null) rows in the user_permission_futures table - if something goes screwy and the user_permission_futures_pkey doesn't exist (i.e. because we already dropped it) then the update was failing; added an `IF EXISTS` to avoid the error. (This is unlikely to happen in production, but doesn't hurt).
1 parent 83bd038 commit 8e5abe6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sogs/migrations/user_perm_futures.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ def migrate(conn, *, check_only):
6868
INSERT INTO user_ban_futures (room, "user", at, banned)
6969
SELECT room, "user", at, banned FROM user_permission_futures WHERE banned is NOT NULL;
7070
71-
ALTER TABLE user_permission_futures DROP CONSTRAINT user_permission_futures_pkey;
71+
DELETE FROM user_permission_futures WHERE read IS NULL AND write IS NULL AND uploads IS NULL;
72+
73+
ALTER TABLE user_permission_futures DROP CONSTRAINT IF EXISTS user_permission_futures_pkey;
7274
ALTER TABLE user_permission_futures DROP COLUMN banned;
7375
"""
7476
)

0 commit comments

Comments
 (0)