From 8b1df3ab0924173566cf988ad1c332ed06325000 Mon Sep 17 00:00:00 2001 From: catborise Date: Fri, 6 Nov 2026 11:01:58 +0300 Subject: [PATCH] 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. --- admin/migrations/0003_create_group_technicians.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/admin/migrations/0003_create_group_technicians.py b/admin/migrations/0003_create_group_technicians.py index 81684428..59d46ef6 100644 --- a/admin/migrations/0003_create_group_technicians.py +++ b/admin/migrations/0003_create_group_technicians.py @@ -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), + ]