- select→code, text→str, number→int 对齐bricks uitype规范 - 表单区域父容器改用VScrollPanel(height:500px)防止超出屏幕 - llmid改为uitype:hidden, 从params_kw.llmid获取值(从llm CRUD tool触发) - 移除llmid的select下拉和label
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Migration script: Move llm.llmcatelogid to llm_catalog_rel.
|
|
Run this AFTER creating the llm_catalog_rel table via build.sh.
|
|
"""
|
|
import asyncio
|
|
from sqlor.dbpools import DBPools
|
|
from appPublic.jsonConfig import getConfig
|
|
from appPublic.log import info, error
|
|
from ahserver.serverenv import ServerEnv
|
|
|
|
async def migrate():
|
|
env = ServerEnv()
|
|
try:
|
|
dbname = env.get_module_dbname('llmage')
|
|
except:
|
|
dbname = 'default'
|
|
|
|
config = getConfig()
|
|
db = DBPools()
|
|
db.databases = config.databases
|
|
|
|
async with db.sqlorContext(dbname) as sor:
|
|
# 1. Migrate data
|
|
print("Migrating data...")
|
|
# Get all llms with a llmcatelogid
|
|
# Note: llmcatelogid still exists in DB until we drop it, or we assume it's there.
|
|
# Assuming it's there.
|
|
sql = "select id, llmcatelogid from llm where llmcatelogid is not null and llmcatelogid != ''"
|
|
rows = await sor.sqlExe(sql, {})
|
|
|
|
if not rows:
|
|
print("No data to migrate.")
|
|
return
|
|
|
|
print(f"Found {len(rows)} records to migrate.")
|
|
|
|
for r in rows:
|
|
# Insert into llm_catalog_rel
|
|
# Use getID() logic or simple uuid, here assuming we can use a function or simple generation
|
|
# but sqlor insert C() is better
|
|
data = {
|
|
'llmid': r['id'],
|
|
'llmcatelogid': r['llmcatelogid']
|
|
}
|
|
await sor.C('llm_catalog_rel', data)
|
|
|
|
print("Migration complete.")
|
|
|
|
# 2. Drop column (Optional but recommended)
|
|
# print("Dropping column...")
|
|
# await sor.sqlExe("alter table llm drop column llmcatelogid", {})
|
|
# print("Column dropped.")
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(migrate())
|