Skip to content

Commit

Permalink
Add default PERMISSION objects
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljcollinsuk committed Sep 3, 2024
1 parent ae39f1f commit beecc7d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ap/database_access/migrations/0002_add_default_permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 5.1 on 2024-09-03 16:07

from django.db import migrations


def forwards(apps, schema_editor):
Permission = apps.get_model("database_access", "Permission")
Permission.objects.bulk_create(
[
Permission(name="SELECT", entity="table", display_name="Select"),
Permission(name="SELECT", entity="database", display_name="Select"),
Permission(name="DESCRIBE", entity="database", display_name="Select"),
]
)


def backwards(apps, schema_editor):
Permission = apps.get_model("database_access", "Permission")
Permission.objects.filter(
name__in=["SELECT", "DESCRIBE"], entity__in=["table", "database"]
).delete()


class Migration(migrations.Migration):
dependencies = [
("database_access", "0001_initial"),
]

operations = [migrations.RunPython(code=forwards, reverse_code=backwards)]

0 comments on commit beecc7d

Please sign in to comment.