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 <discodedisco@outlook.com> Git commit message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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),
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user