apiVersion: batch/v1
kind: Job
metadata:
  name: fusero-backend-db-init
spec:
  backoffLimit: 0
  template:
    metadata:
      name: fusero-backend-db-init
    spec:
      containers:
        - name: migrate-seed
          image: {{ .Values.backend.image }}
          command: ["/bin/sh", "-c"]
          args:
            - |
              echo "Running migrations and seeds..." && \
              npx mikro-orm migration:up && \
              npm run seed
          env:
            {{- range $key, $val := .Values.backend.env }}
            - name: {{ $key }}
              value: "{{ $val }}"
            {{- end }}
      restartPolicy: Never
