apiVersion: batch/v1
kind: Job
metadata:
  name: database-migrations-job
  labels:
    env: {{ .Values.deploymentEnvironment }}
    app: boost
  annotations:
    "helm.sh/hook": pre-install,pre-upgrade
    "helm.sh/hook-weight": "-1"
spec:
  ttlSecondsAfterFinished: 3600
  backoffLimit: 4
  template:
    spec:
      restartPolicy: OnFailure
      volumes:
{{ toYaml .Values.Volumes | indent 6 }}
      imagePullSecrets:
        - name: revsys-docker-registry
      containers:
        - name: database-migrations
          image: {{ .Values.Image }}:{{ .Values.ImageTag }}
          command: ["/bin/sh", "-c"]
          args:
            - "./manage.py migrate --noinput"
          env:
{{ toYaml .Values.Env | indent 10 }}
          volumeMounts:
{{ toYaml .Values.VolumeMounts | indent 10 }}
