mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
this helps catching some _real_ errors while saving us from having to format automatically generated code
25 lines
660 B
Python
25 lines
660 B
Python
from django.db import migrations
|
|
|
|
|
|
def unfill_stored_event_count(apps, schema_editor):
|
|
Project = apps.get_model("projects", "Project")
|
|
Project.objects.all().update(stored_event_count=0)
|
|
|
|
|
|
def fill_stored_event_count(apps, schema_editor):
|
|
Project = apps.get_model("projects", "Project")
|
|
for project in Project.objects.all():
|
|
project.stored_event_count = project.event_set.count()
|
|
project.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("projects", "0010_project_stored_event_count"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(fill_stored_event_count, unfill_stored_event_count),
|
|
]
|