|
1 | 1 | # Generated by Django 5.2.6 on 2025-10-11 02:54 |
| 2 | +from concurrent.futures import ThreadPoolExecutor |
2 | 3 | from functools import reduce |
3 | 4 |
|
4 | 5 | from django.db import migrations, models |
|
8 | 9 | from common.utils.common import group_by |
9 | 10 |
|
10 | 11 |
|
| 12 | +def workspace_user_role_mapping_model_exists(workspace_user_role_mapping_model): |
| 13 | + try: |
| 14 | + QuerySet(workspace_user_role_mapping_model).first() |
| 15 | + except Exception as e: |
| 16 | + return False |
| 17 | + return False |
| 18 | + |
11 | 19 | def delete_auth(apps,folder_model): |
12 | 20 | workspace_user_resource_permission_model = apps.get_model('system_manage', 'WorkspaceUserResourcePermission') |
13 | 21 | QuerySet(workspace_user_resource_permission_model).filter(target__in=QuerySet(folder_model).values_list('id')).delete() |
@@ -35,6 +43,13 @@ def auth_folder(apps, schema_editor): |
35 | 43 | workspace_user_resource_permission_model = apps.get_model('system_manage', 'WorkspaceUserResourcePermission') |
36 | 44 |
|
37 | 45 | workspace_user_role_mapping_model = DatabaseModelManage.get_model("workspace_user_role_mapping") |
| 46 | + |
| 47 | + with ThreadPoolExecutor(max_workers=3) as executor: |
| 48 | + future = executor.submit(workspace_user_role_mapping_model_exists, workspace_user_role_mapping_model) |
| 49 | + exists = future.result() |
| 50 | + if not exists: |
| 51 | + workspace_user_role_mapping_model = None |
| 52 | + |
38 | 53 | if workspace_user_role_mapping_model is None: |
39 | 54 | workspace_user_role_mapping_model_workspace_dict = { |
40 | 55 | 'default': [WorkspaceUserRoleMapping('default', '', u.id) for u in QuerySet(user_model).all()]} |
|
0 commit comments