apiVersion: batch/v1
kind: Job
metadata:
  name: rails-migrations
spec:
  backoffLimit: 4
  template:
    spec:
      containers:
        - command:
            - sh
            - "-c"
            - "bundle exec rake db:migrate"
          env:
            - name: DB_HOST
              valueFrom:
                secretKeyRef:
                  key: rds_instance_address
                  name: parliamentary-questions-staging-rds
            - name: PGPASSWORD
              valueFrom:
                secretKeyRef:
                  key: database_password
                  name: parliamentary-questions-staging-rds
            - name: PGUSER
              valueFrom:
                secretKeyRef:
                  key: database_username
                  name: parliamentary-questions-staging-rds
          envFrom:
            - configMapRef:
                name: environment-variables
            - secretRef:
                name: pq-secrets
          imagePullPolicy: Always
          name: parliamentary-questions-rails-app
      restartPolicy: OnFailure
