From b08839569d679ec6c5a6b556d37863d4085ab1b2 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 11 Feb 2024 13:01:26 +0200 Subject: [PATCH] retrofix owner_id --- files/routes/admin.py | 12 ++++++++++++ migrations/20240211-retrofix-owner-id.sql | 1 + 2 files changed, 13 insertions(+) create mode 100644 migrations/20240211-retrofix-owner-id.sql diff --git a/files/routes/admin.py b/files/routes/admin.py index 39812c004..1fec6982d 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -2243,3 +2243,15 @@ def unmark_effortpost(pid, v): send_repeatable_notification(p.author_id, f":marseyitsover: @{v.username} (a site admin) has unmarked [{p.title}](/post/{p.id}) as an effortpost. {coins} coins have been deducted from you. :!marseyitsover:") return {"message": "Post has been unmarked as an effortpost!"} + +@app.get("/retrofix") +@limiter.limit('1/day') +@limiter.limit('1/day', key_func=get_ID) +@admin_level_required(5) +def retrofix(v): + groups = g.db.query(Group) + for group in groups: + group.owner_id = group.memberships[0].user_id + g.db.add(group) + + return 'nig' diff --git a/migrations/20240211-retrofix-owner-id.sql b/migrations/20240211-retrofix-owner-id.sql new file mode 100644 index 000000000..24ebd2eaa --- /dev/null +++ b/migrations/20240211-retrofix-owner-id.sql @@ -0,0 +1 @@ +alter table groups alter column owner_id set not null;