deploy.sh增加表结构一致性检查

This commit is contained in:
super committed 2026-03-29 13:04:08 +08:00
1 parent f5d3e275ac
commit 70f95e9f5c
1 file changed
+11 -1
+11 -1
View File
@@ -63,9 +63,19 @@ $DC_CMD up -d --build
echo "🗄️ 执行数据库表结构更新..."
$DC_CMD exec -T hxops-backend flask --app manage.py db upgrade || { echo "❌ 数据库迁移失败"; exit 1; }
# 5.1 SQLAlchemy 兜底同步(补齐缺失表,不替代 Alembic 迁移)
echo "🧩 执行 SQLAlchemy 表结构兜底同步..."
$DC_CMD exec -T hxops-backend python - <<'PY' || { echo "❌ SQLAlchemy 表结构同步失败"; exit 1; }
from app import create_app, db
app = create_app('production')
with app.app_context():
db.create_all()
print("SQLAlchemy create_all completed.")
PY
# 6. 清理未使用镜像
echo "🧹 清理旧镜像..."
docker image prune -f
echo "✅ 部署完成!"