mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-25 17:22:55 +00:00
fix: File migration error
This commit is contained in:
parent
66a95d1c5f
commit
642aa6759a
|
|
@ -1,13 +1,14 @@
|
|||
# Generated by Django 5.2.8 on 2025-12-19 09:37
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
import uuid_utils.compat
|
||||
from django.db import migrations, models
|
||||
from django.db.models import QuerySet
|
||||
|
||||
from knowledge.models import Knowledge
|
||||
|
||||
|
||||
def resource_mapping(apps, schema_editor):
|
||||
from system_manage.models.resource_mapping import ResourceMapping
|
||||
def get_initialization_resource_mapping():
|
||||
from django.db.models import QuerySet
|
||||
from application.flow.tools import get_workflow_resource, get_node_handle_callback, \
|
||||
get_instance_resource
|
||||
|
|
@ -28,7 +29,7 @@ def resource_mapping(apps, schema_editor):
|
|||
resource_mapping_list += workflow_mapping
|
||||
resource_mapping_list += instance_mapping
|
||||
except:
|
||||
continue
|
||||
pass
|
||||
knowledge_ids = list(Knowledge.objects.values_list('id', flat=True))
|
||||
for knowledge_id in knowledge_ids:
|
||||
try:
|
||||
|
|
@ -46,8 +47,17 @@ def resource_mapping(apps, schema_editor):
|
|||
|
||||
resource_mapping_list += instance_mapping
|
||||
except:
|
||||
continue
|
||||
QuerySet(ResourceMapping).bulk_create(resource_mapping_list)
|
||||
pass
|
||||
|
||||
return resource_mapping_list
|
||||
|
||||
|
||||
def resource_mapping(apps, schema_editor):
|
||||
from system_manage.models.resource_mapping import ResourceMapping
|
||||
with ThreadPoolExecutor(max_workers=3) as executor:
|
||||
future = executor.submit(get_initialization_resource_mapping)
|
||||
resource_mapping_list = future.result()
|
||||
QuerySet(ResourceMapping).bulk_create(resource_mapping_list)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
@ -79,5 +89,5 @@ class Migration(migrations.Migration):
|
|||
'db_table': 'resource_mapping',
|
||||
},
|
||||
),
|
||||
migrations.RunPython(resource_mapping)
|
||||
migrations.RunPython(resource_mapping, atomic=False)
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in New Issue