70 lines
2.0 KiB
YAML
70 lines
2.0 KiB
YAML
---
|
|
# =============================================================================
|
|
# Database schema rollout Job
|
|
# Runtime Flyway is intentionally disabled. This hook applies the reviewed,
|
|
# idempotent Epic #360 schema bundle before the application rollout.
|
|
# =============================================================================
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: ljwx-health-init-db
|
|
namespace: ljwx-health
|
|
labels:
|
|
app: ljwx-health
|
|
component: init-db
|
|
annotations:
|
|
argocd.argoproj.io/hook: PreSync
|
|
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
|
|
argocd.argoproj.io/sync-wave: "0"
|
|
spec:
|
|
ttlSecondsAfterFinished: 60
|
|
backoffLimit: 1
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: ljwx-health
|
|
component: init-db
|
|
spec:
|
|
restartPolicy: Never
|
|
containers:
|
|
- name: schema-rollout
|
|
image: postgres:18-alpine
|
|
command:
|
|
- sh
|
|
- -ec
|
|
- |
|
|
for file in /schema/*.sql; do
|
|
echo "Applying ${file##*/}"
|
|
psql \
|
|
--host="${DB_HOST}" \
|
|
--port="${DB_PORT}" \
|
|
--username="${DB_USER}" \
|
|
--dbname="${DB_NAME}" \
|
|
--set=ON_ERROR_STOP=1 \
|
|
--file="${file}"
|
|
done
|
|
envFrom:
|
|
- configMapRef:
|
|
name: ljwx-health-config
|
|
env:
|
|
- name: PGPASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: ljwx-health-secret
|
|
key: DB_PASSWORD
|
|
volumeMounts:
|
|
- name: schema
|
|
mountPath: /schema
|
|
readOnly: true
|
|
resources:
|
|
requests:
|
|
cpu: 50m
|
|
memory: 64Mi
|
|
limits:
|
|
cpu: 250m
|
|
memory: 256Mi
|
|
volumes:
|
|
- name: schema
|
|
configMap:
|
|
name: ljwx-health-epic-360-schema
|