chore(release): add alembic preflight check

This commit is contained in:
Xiaoxia AI
2026-06-21 13:01:49 +08:00
parent ccb6786e0b
commit e98dfc9ffb
3 changed files with 136 additions and 1 deletions
+7 -1
View File
@@ -51,12 +51,18 @@ ls -lh "$BACKUP_DIR"
发布前只读检查生产库状态:
```bash
docker exec xiaoxia-api-production python /app/scripts/alembic_preflight.py
```
也可手动检查:
```bash
docker exec xiaoxia-postgres psql -U xiaoxia -d xiaoxia_saas -Atc "select to_regclass('public.alembic_version');"
docker exec xiaoxia-postgres psql -U xiaoxia -d xiaoxia_saas -Atc "select count(*) from pg_tables where schemaname='public' and tablename != 'alembic_version';"
```
判断规则:
脚本 `recommended_action` 判断规则:
- 已存在 `alembic_version`:执行 `alembic upgrade head`
- 有业务表但没有 `alembic_version`:先执行 `alembic stamp head`,再执行 `alembic upgrade head`