apiVersion: batch/v1
kind: Job
metadata:
  name: django-migrations
  namespace: performance
spec:
  ttlSecondsAfterFinished: 43200
  template:
    spec:
      containers:
        - name: performance-storage-service-migration
          image: "{{ pss_container_image }}"
          command: ["python",  "manage.py", "migrate", "--noinput"]
          imagePullPolicy: "{{ image_pull_policy }}"
          env:
            - name: ENV
              value: "{{ env }}"
            - name: PSS_DATABASE_NAME
              value: "{{ pss_db_name }}"
            - name: PSS_DATABASE_PORT
              value: "5432"
            - name: PSS_DATABASE_USER
              valueFrom:
                secretKeyRef:
                  name: "secrets-{{ env }}"
                  key: pss_db_user
            - name: PSS_DATABASE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: "secrets-{{ env }}"
                  key: pss_db_password
            - name: PSS_CREATOR_USER
              valueFrom:
                secretKeyRef:
                  name: "secrets-{{ env }}"
                  key: pss_creator_user
            - name: PSS_CREATOR_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: "secrets-{{ env }}"
                  key: pss_creator_password
            - name: PSS_POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: GITHUB_APP_WEBHOOK_SECRET
              valueFrom:
                secretKeyRef:
                  name: "secrets-{{ env }}"
                  key: webhook_secret 
            - name: GITHUB_APP_PRIVATE_KEY
              valueFrom:
                secretKeyRef:
                  name: "secrets-{{ env }}"
                  key: github_private_key

      restartPolicy: Never
  backoffLimit: 5