apiVersion: batch/v1
kind: Job
metadata:
  name: slotlist-migration-job
  namespace: slotlist
spec:
  template:
    metadata:
      name: slotlist-migration-job
    spec:
      containers:
      - name: slotlist-migration-job
        image: eu.gcr.io/slotlist-info/slotlist/backend:latest
        command: ["yarn", "migrate"]
        env:
          - name: CONFIG_DATABASE_HOST
            value: postgres.kube-system.svc.cluster.local
          - name: CONFIG_DATABASE_PORT
            value: "5432"
          - name: CONFIG_DATABASE_DATABASE
            valueFrom:
              secretKeyRef:
                name: slotlist-backend
                key: postgres_database
          - name: CONFIG_DATABASE_USERNAME
            valueFrom:
              secretKeyRef:
                name: slotlist-backend
                key: postgres_username
          - name: CONFIG_DATABASE_PASSWORD
            valueFrom:
              secretKeyRef:
                name: slotlist-backend
                key: postgres_password
      restartPolicy: Never