mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +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
66fdfc3c11
commit
ebf49f369e
1 changed files with 8 additions and 6 deletions
|
|
@ -1,15 +1,17 @@
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
def apply_migration(apps, schema_editor):
|
def apply_migration(apps, schema_editor):
|
||||||
Group = apps.get_model('auth', 'Group')
|
Group = apps.get_model("auth", "Group")
|
||||||
Group.objects.create(name='Technicians')
|
Group.objects.get_or_create(name="Technicians")
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('admin', '0002_auto_20200609_0830'),
|
("admin", "0002_auto_20200609_0830"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RunPython(apply_migration)
|
migrations.RunPython(apply_migration, migrations.RunPython.noop),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue