apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: migrates.code.dev
  annotations:
    controller-gen.kubebuilder.io/version: v0.16.0
spec:
  group: code.dev
  names:
    kind: Migrate
    listKind: MigrateList
    plural: migrates
    singular: migrate
    shortNames:
      - mig
  scope: Namespaced
  versions:
    - name: v1
      served: true
      storage: true
      subresources:
        status: {}
      additionalPrinterColumns:
        - name: Status
          jsonPath: .status.phase
          type: string
        - name: Age
          jsonPath: .metadata.creationTimestamp
          type: date
      schema:
        openAPIV3Schema:
          type: object
          required: [spec]
          properties:
            apiVersion:
              type: string
            kind:
              type: string
            metadata:
              type: object
            spec:
              type: object
              required: []
              properties:
                image:
                  type: string
                  default: myapp/migrate:latest
                env:
                  type: array
                  description: "Must include APP_DATABASE_URL"
                  items:
                    type: object
                    required: [name]
                    properties:
                      name:
                        type: string
                      value:
                        type: string
                      valueFrom:
                        type: object
                        properties:
                          secretRef:
                            type: object
                            required: [name, secretName, secretKey]
                            properties:
                              name:
                                type: string
                              secretName:
                                type: string
                              secretKey:
                                type: string
                command:
                  type: string
                  default: up
                  description: "Migration command: up, down, fresh, refresh, reset"
                backoffLimit:
                  type: integer
                  default: 3
            status:
              type: object
              properties:
                phase:
                  type: string
                startTime:
                  type: string
                completionTime:
                  type: string
