From d1d7e652e4fd9ec791b5e7e81e122ff256ddfeb2 Mon Sep 17 00:00:00 2001 From: Fang Yi Liu Date: Mon, 17 Jun 2024 10:57:19 -0700 Subject: [PATCH] add reverse function to permissiontype initial data migration --- app/data/migrations/0004_permissiontype_seed.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/data/migrations/0004_permissiontype_seed.py b/app/data/migrations/0004_permissiontype_seed.py index aa58a62d..c8303220 100644 --- a/app/data/migrations/0004_permissiontype_seed.py +++ b/app/data/migrations/0004_permissiontype_seed.py @@ -3,7 +3,7 @@ from core.models import PermissionType -def run(__code__, __reverse_code__): +def insert_data(__code__, __reverse_code__): items = [ (1, "adminGlobal", "Granted to People Depo Admins. Can CRUD anything."), ( @@ -46,8 +46,11 @@ def run(__code__, __reverse_code__): PermissionType.objects.create(uuid=uuid, name=name, description=description) +def clear_table(__code__, __reverse_code__): + PermissionType.objects.all().delete() + + class Migration(migrations.Migration): - initial = True dependencies = [("data", "0003_sdg_seed")] - operations = [migrations.RunPython(run, migrations.RunPython.noop)] + operations = [migrations.RunPython(insert_data, clear_table)]