chore(release): add alembic preflight check
This commit is contained in:
@@ -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`。
|
||||
|
||||
Reference in New Issue
Block a user