forked from xiaohei/taiji-AI-PAD
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
"""验证迁移结果"""
|
|
import asyncio
|
|
from database import AsyncSessionLocal
|
|
from sqlalchemy import text
|
|
|
|
async def verify_migration():
|
|
async with AsyncSessionLocal() as session:
|
|
# 检查新增字段
|
|
result = await session.execute(text("""
|
|
SELECT column_name, data_type
|
|
FROM information_schema.columns
|
|
WHERE table_name='agent_billing_records'
|
|
AND column_name IN ('tools_used', 'request_id', 'eu_consumed')
|
|
ORDER BY column_name
|
|
"""))
|
|
|
|
print("\n✅ 新增字段验证:")
|
|
rows = result.fetchall()
|
|
for row in rows:
|
|
print(f" - {row[0]}: {row[1]}")
|
|
|
|
# 检查索引
|
|
idx_result = await session.execute(text("""
|
|
SELECT indexname
|
|
FROM pg_indexes
|
|
WHERE tablename='agent_billing_records'
|
|
AND indexname LIKE '%tools_used%' OR indexname LIKE '%request_id%'
|
|
"""))
|
|
|
|
print("\n✅ 新增索引:")
|
|
idx_rows = idx_result.fetchall()
|
|
for row in idx_rows:
|
|
print(f" - {row[0]}")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(verify_migration())
|