apiVersion: batch/v1
kind: Job
metadata:
  name: api-event-store-migration-job
  labels:
    project: sob
    layer: api
spec:
  ttlSecondsAfterFinished: 60
  template:
    spec:
      restartPolicy: Never
      containers:
        - name: api-event-store-migration-job
          image: eu.gcr.io/aperturedevs/sob-api-php:stable
          command: ["/bin/sh", "-c", "./bin/console doctrine:database:drop --force --if-exists --connection=relational_model && ./bin/console doctrine:database:create --connection=relational_model && ./bin/console doctrine:migrations:migrate --configuration=src/Infrastructure/Persistence/RelationalModel/Migration/doctrine_migrations.yaml --db relational_model --no-interaction && ./bin/console hautelook:fixtures:load --manager=relational_model --append --no-interaction"]
          env:
            - name: EVENT_STORE_URL
              valueFrom:
                secretKeyRef:
                  name: sob-secret
                  key: api-event-store-url
            - name: RELATIONAL_DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: sob-secret
                  key: api-relational-database-url
            - name: MESSENGER_TRANSPORT_DSN
              valueFrom:
                secretKeyRef:
                  name: sob-secret
                  key: api-messenger-transport-dsn
            - name: APP_SECRET
              valueFrom:
                secretKeyRef:
                  name: sob-secret
                  key: api-secret
            - name: APP_ENV
              valueFrom:
                configMapKeyRef:
                  name: api-configmap
                  key: environment
            - name: CORS_ALLOW_ORIGIN
              valueFrom:
                configMapKeyRef:
                  name: api-configmap
                  key: cors
            - name: FRONTEND_URL
              valueFrom:
                configMapKeyRef:
                  name: api-configmap
                  key: frontend_url
          resources:
            limits:
              cpu: "100m"
              memory: "128Mi"
            requests:
              cpu: "1m"
              memory: "128Mi"
