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:
parent
52cb23eefd
commit
8b1df3ab09
1 changed files with 8 additions and 6 deletions
|
|
@ -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),
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue