apiVersion: batch/v1
kind: Job
metadata:
  name: migrate
spec:
  template:
    spec:
      containers:
      - name: mastodon
        image: tootsuite/mastodon:v3.5.3@sha256:bd1d81cd1948cb29e9fd640c902d377fc84fe2567589aca0c290b760d57b6a2b
        env:
        - name: REDIS_HOST
          valueFrom:
            secretKeyRef:
              name: redislabs-credentials
              key: hostname
        - name: REDIS_PORT
          valueFrom:
            secretKeyRef:
              name: redislabs-credentials
              key: port
        - name: REDIS_PASSWORD
          valueFrom:
            secretKeyRef:
              name: redislabs-credentials
              key: password
        - name: DB_HOST
          valueFrom:
            secretKeyRef:
              name: cloudsql-db-credentials
              key: hostname
        - name: DB_PORT
          valueFrom:
            secretKeyRef:
              name: cloudsql-db-credentials
              key: port
        - name: DB_USER
          valueFrom:
            secretKeyRef:
              name: cloudsql-db-credentials
              key: username
        - name: DB_PASS
          valueFrom:
            secretKeyRef:
              name: cloudsql-db-credentials
              key: password
        - name: SECRET_KEY_BASE
          valueFrom:
            secretKeyRef:
              name: mastodon-credentials
              key: secret-key-base
        - name: OTP_SECRET
          valueFrom:
            secretKeyRef:
              name: mastodon-credentials
              key: otp-secret
        command: ["./bin/rails", "db:migrate"]
      restartPolicy: Never
