apiVersion: batch/v1
kind: Job
metadata:
  name: foxhunt-migrate
  namespace: foxhunt
  labels:
    app.kubernetes.io/part-of: foxhunt
    app.kubernetes.io/component: migration
spec:
  backoffLimit: 3
  template:
    spec:
      restartPolicy: Never
      imagePullSecrets:
        - name: gitlab-registry
      containers:
        - name: migrate
          image: rg.fr-par.scw.cloud/foxhunt/api:latest
          command: ["sqlx", "migrate", "run"]
          env:
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: db-credentials
                  key: password
            - name: DATABASE_URL
              value: "postgresql://foxhunt:$(DB_PASSWORD)@postgres:5432/foxhunt"
          resources:
            requests:
              memory: "64Mi"
              cpu: "50m"
            limits:
              memory: "256Mi"
              cpu: "200m"
