1
- # Generated manually to create new Organization model
1
+ # Generated manually to create new Organization model and clear dab_rbac data
2
2
3
3
from django .db import migrations , models
4
4
5
5
6
+ def clear_dab_rbac_data (apps , schema_editor ):
7
+ """Delete all entries from dab_rbac models"""
8
+ db_alias = schema_editor .connection .alias
9
+
10
+ # Get all dab_rbac models
11
+ from django .apps import apps as django_apps
12
+ dab_rbac_config = django_apps .get_app_config ('dab_rbac' )
13
+
14
+ # Delete all data from dab_rbac models in reverse dependency order
15
+ for model in reversed (dab_rbac_config .get_models ()):
16
+ model .objects .using (db_alias ).all ().delete ()
17
+
18
+
19
+ def reverse_clear_dab_rbac_data (apps , schema_editor ):
20
+ """Reverse operation - no-op since we can't restore deleted data"""
21
+ pass
22
+
23
+
6
24
class Migration (migrations .Migration ):
7
25
8
26
dependencies = [
9
27
("organizations" , "0004_organization_enable_anonymization" ),
28
+ ("dab_rbac" , "0004_remote_permissions_additions" ),
29
+ ]
30
+
31
+ run_before = [
32
+ ("dab_rbac" , "0005_remote_permissions_data" ),
10
33
]
11
34
12
35
operations = [
@@ -29,4 +52,8 @@ class Migration(migrations.Migration):
29
52
"ordering" : ["id" ],
30
53
},
31
54
),
55
+ migrations .RunPython (
56
+ clear_dab_rbac_data ,
57
+ reverse_clear_dab_rbac_data ,
58
+ ),
32
59
]
0 commit comments