29 lines
743 B
Python
29 lines
743 B
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""检查 alembic 迁移版本"""
|
||
|
|
|
||
|
|
import asyncio
|
||
|
|
import asyncpg
|
||
|
|
import os
|
||
|
|
|
||
|
|
async def check_heads():
|
||
|
|
conn = await asyncpg.connect(
|
||
|
|
host='postgres',
|
||
|
|
user='wecom',
|
||
|
|
password='wecom_secret_2026',
|
||
|
|
database='wecom_it_desk'
|
||
|
|
)
|
||
|
|
|
||
|
|
# 检查 alembic_version 表
|
||
|
|
rows = await conn.fetch('SELECT version_num, branch_from, depends_on FROM alembic_version ORDER BY rank')
|
||
|
|
|
||
|
|
if not rows:
|
||
|
|
print("No migration versions found!")
|
||
|
|
else:
|
||
|
|
print(f"Found {len(rows)} migration version(s):")
|
||
|
|
for r in rows:
|
||
|
|
print(f" - {r['version_num']} (branch_from: {r['branch_from']}, depends_on: {r['depends_on']})")
|
||
|
|
|
||
|
|
await conn.close()
|
||
|
|
|
||
|
|
asyncio.run(check_heads())
|