1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-09 19:56:48 +00:00

fix(admin): the Technicians group migration can run on a database that has it

It created the group with objects.create and had no reverse: it failed
when the group existed and could not be unapplied. It now uses
get_or_create, and its reverse does nothing.
This commit is contained in:
catborise 2026-11-06 11:01:58 +03:00
parent 52cb23eefd
commit 8b1df3ab09

View file

@ -1,15 +1,17 @@
from django.db import migrations
def apply_migration(apps, schema_editor):
Group = apps.get_model('auth', 'Group')
Group.objects.create(name='Technicians')
Group = apps.get_model("auth", "Group")
Group.objects.get_or_create(name="Technicians")
class Migration(migrations.Migration):
dependencies = [
('admin', '0002_auto_20200609_0830'),
]
("admin", "0002_auto_20200609_0830"),
]
operations = [
migrations.RunPython(apply_migration)
]
migrations.RunPython(apply_migration, migrations.RunPython.noop),
]