feat: add migration to insert default data for ToolFolder and KnowledgeFolder
This commit is contained in:
parent
9877c825bc
commit
c758059fe4
@ -12,8 +12,8 @@ from django.db import migrations, models
|
||||
|
||||
def insert_default_data(apps, schema_editor):
|
||||
# 创建一个根模块(没有父节点)
|
||||
QuerySet(application.models.application.ApplicationFolder).create(id='root', name='根目录',
|
||||
user_id='f0dd8f71-e4ee-11ee-8c84-a8a1595801ab')
|
||||
QuerySet(application.models.application.ApplicationFolder).create(id='default', name='根目录',
|
||||
user_id='f0dd8f71-e4ee-11ee-8c84-a8a1595801ab', workspace_id='default')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
@ -7,6 +7,13 @@ import mptt.fields
|
||||
import uuid_utils.compat
|
||||
from django.db import migrations, models
|
||||
|
||||
from knowledge.models import KnowledgeFolder
|
||||
|
||||
|
||||
def insert_default_data(apps, schema_editor):
|
||||
# 创建一个根模块(没有父节点)
|
||||
KnowledgeFolder.objects.create(id='default', name='根目录', user_id='f0dd8f71-e4ee-11ee-8c84-a8a1595801ab', workspace_id='default')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
@ -168,4 +175,5 @@ class Migration(migrations.Migration):
|
||||
'db_table': 'problem_paragraph_mapping',
|
||||
},
|
||||
),
|
||||
migrations.RunPython(insert_default_data),
|
||||
]
|
||||
|
||||
@ -1,10 +1,20 @@
|
||||
# Generated by Django 5.2 on 2025-05-15 04:04
|
||||
import os
|
||||
|
||||
import django.db.models.deletion
|
||||
import mptt.fields
|
||||
import uuid_utils.compat
|
||||
from django.db import migrations, models
|
||||
|
||||
from common.utils.common import get_file_content
|
||||
from maxkb.conf import PROJECT_DIR
|
||||
from tools.models import ToolFolder
|
||||
|
||||
|
||||
def insert_default_data(apps, schema_editor):
|
||||
# 创建一个根模块(没有父节点)
|
||||
ToolFolder.objects.create(id='default', name='根目录', user_id='f0dd8f71-e4ee-11ee-8c84-a8a1595801ab', workspace_id='default')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
@ -35,6 +45,7 @@ class Migration(migrations.Migration):
|
||||
'db_table': 'tool_folder',
|
||||
},
|
||||
),
|
||||
migrations.RunPython(insert_default_data),
|
||||
migrations.CreateModel(
|
||||
name='Tool',
|
||||
fields=[
|
||||
@ -60,4 +71,5 @@ class Migration(migrations.Migration):
|
||||
'db_table': 'tool',
|
||||
},
|
||||
),
|
||||
migrations.RunSQL(get_file_content(os.path.join(PROJECT_DIR, "apps", "tools", 'migrations', 'internal_tool.sql')))
|
||||
]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user