Skip to content

Commit

Permalink
add reverse function to permissiontype initial data migration
Browse files Browse the repository at this point in the history
  • Loading branch information
fyliu committed Aug 12, 2024
1 parent dcabb0a commit d1d7e65
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/data/migrations/0004_permissiontype_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
(
Expand Down Expand Up @@ -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)]

0 comments on commit d1d7e65

Please sign in to comment.