apiVersion: batch/v1
kind: Job
metadata:
  name: django-migrations
spec:
  template:
    spec:
      containers:
        - name: django
          image: willwcchan/visual-option-chain-graph
          command: ["python", "manage.py", "migrate"]
          env:
            - name: POSTGRES_USER
              valueFrom:
                secretKeyRef:
                  name: postgres-credentials
                  key: user

            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: postgres-credentials
                  key: password

            - name: POSTGRES_HOST
              value: postgres-service

            - name: SECRET_KEY
              valueFrom:
                secretKeyRef:
                  name: app-secret
                  key: SECRET_KEY

            - name: TRADIER_API_KEY
              valueFrom:
                secretKeyRef:
                  name: app-secret
                  key: TRADIER_API_KEY

            - name: EMAIL_HOST_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: app-secret
                  key: EMAIL_HOST_PASSWORD

      restartPolicy: Never
  backoffLimit: 2
