From 763d555f0c56e4a59e32cf85c6b99be4ff0f222c Mon Sep 17 00:00:00 2001 From: Disco DeDisco Date: Tue, 28 Apr 2026 01:31:36 -0400 Subject: [PATCH] backfill super-schizo + super-nomad Notes to existing superusers Migration 0003: grants both Notes to all existing is_superuser=True users. Covers accounts created before the post_save signal was wired. Code architected by Disco DeDisco Git commit message Co-Authored-By: Claude Sonnet 4.6 --- ...rant_super_notes_to_existing_superusers.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/apps/drama/migrations/0003_grant_super_notes_to_existing_superusers.py diff --git a/src/apps/drama/migrations/0003_grant_super_notes_to_existing_superusers.py b/src/apps/drama/migrations/0003_grant_super_notes_to_existing_superusers.py new file mode 100644 index 0000000..b742842 --- /dev/null +++ b/src/apps/drama/migrations/0003_grant_super_notes_to_existing_superusers.py @@ -0,0 +1,27 @@ +"""Backfill super-schizo and super-nomad Notes for all existing superusers.""" +from django.db import migrations +from django.utils import timezone + + +def grant_super_notes(apps, schema_editor): + User = apps.get_model("lyric", "User") + Note = apps.get_model("drama", "Note") + now = timezone.now() + for user in User.objects.filter(is_superuser=True): + for slug in ("super-schizo", "super-nomad"): + Note.objects.get_or_create( + user=user, slug=slug, + defaults={"earned_at": now}, + ) + + +class Migration(migrations.Migration): + + dependencies = [ + ("drama", "0002_initial"), + ("lyric", "0001_initial"), + ] + + operations = [ + migrations.RunPython(grant_super_notes, migrations.RunPython.noop), + ]