feat: 数据库迁移支持
Some checks failed
Deploy to K3s / deploy (push) Failing after 3m52s

This commit is contained in:
2025-12-20 19:58:47 +08:00
parent 59529519e3
commit d3a7d03be7
7 changed files with 87 additions and 15 deletions

View File

@@ -0,0 +1,28 @@
apiVersion: batch/v1
kind: Job
metadata:
name: backend-migration
spec:
backoffLimit: 0 # 失败不自动重试(防止重复执行)
template:
spec:
restartPolicy: Never
containers:
- name: migration
image: localhost:5000/backend:IMAGE_TAG
imagePullPolicy: Always
command:
- sh
- -c
- |
echo "Running database migrations..."
node ./node_modules/typeorm/cli.js migration:run \
-d dist/data-source.js
envFrom:
# 和 backend Deployment 用同一套
- secretRef:
name: backend-secret
- secretRef:
name: postgres-secret