---
# Create some data that will be restored.
apiVersion: batch/v1
kind: Job
metadata:
  name: original-data
  labels: { postgres-operator-test: kuttl }
spec:
  backoffLimit: 3
  template:
    metadata:
      labels: { postgres-operator-test: kuttl }
    spec:
      restartPolicy: Never
      containers:
        - name: psql
          image: ${KUTTL_PSQL_IMAGE}
          env:
            - name: PGURI
              valueFrom: { secretKeyRef: { name: original-pguser-original, key: uri } }

            # Do not wait indefinitely.
            - { name: PGCONNECT_TIMEOUT, value: '5' }

          command:
            - psql
            - $(PGURI)
            - --set=ON_ERROR_STOP=1
            - --command
            - |
              CREATE TABLE important (data) AS VALUES ('treasure');
