Daybook: a self-hosted, multi-user Django + DRF app where agents, scripts, or people publish artifacts and each logged-in user browses their own time-ordered, label-filterable feed. This squashes prior local development history (kept privately on a separate branch) into a single clean starting point for the public repository. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
27 lines
648 B
Python
27 lines
648 B
Python
from django.db import migrations
|
|
|
|
|
|
def backfill_owner(apps, schema_editor):
|
|
User = apps.get_model("auth", "User")
|
|
Artifact = apps.get_model("artifacts", "Artifact")
|
|
|
|
first_superuser = User.objects.filter(is_superuser=True).order_by("date_joined").first()
|
|
if first_superuser is None:
|
|
return
|
|
|
|
Artifact.objects.filter(owner__isnull=True).update(owner=first_superuser)
|
|
|
|
|
|
def noop_reverse(apps, schema_editor):
|
|
pass
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("artifacts", "0005_add_owner_nullable"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(backfill_owner, noop_reverse),
|
|
]
|