openapi: "3.0.3"
info:
  title: "Multi-tenant fixture for a CI walkthrough"
  version: "1.0.0"
  description: "The tenant slug is unique, and a CI job that runs twice against the same database has to de-duplicate it. The tenant_users email is globally unique even though the role is scoped to the tenant, which is how the multi-tenant schema actually works. The role enum has three members and the owner role is the one a policy check looks for. The plan enum mirrors the pricing page, which makes the fixture usable for a pricing test as well."
paths: {}
x-domain-id: "tut_tenants"
x-dialect: "postgres"
components:
  schemas:
    tenants:
      type: "object"
      x-primary-key: "id"
      required: ["id", "slug", "plan"]
      properties:
        id:
          type: "string"
          format: "uuid"
        slug:
          type: "string"
          x-unique: true
        plan:
          type: "string"
          enum: ["free", "pro", "enterprise"]
    tenant_users:
      type: "object"
      x-primary-key: "id"
      required: ["id", "tenant_id", "email", "role"]
      properties:
        id:
          type: "string"
          format: "uuid"
        tenant_id:
          $ref: "#/components/schemas/tenants"
        email:
          type: "string"
          format: "email"
          x-unique: true
        role:
          type: "string"
          enum: ["owner", "admin", "member"]
