{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gmr.github.io/pglifecycle/schemata/operator_class.json",
  "title": "Operator Class",
  "description": "An operator class (CREATE OPERATOR CLASS): how an index method uses the operators and support functions of a data type.\n",
  "type": "object",
  "properties": {
    "name": {
      "title": "Name",
      "description": "The name of the operator class.",
      "type": "string"
    },
    "schema": {
      "title": "Schema",
      "description": "The schema the operator class is created in.",
      "type": "string"
    },
    "owner": {
      "title": "Owner",
      "description": "The role that owns the operator class.",
      "type": "string"
    },
    "method": {
      "title": "Index Method",
      "description": "The index access method the class is for (USING).",
      "type": "string"
    },
    "data_type": {
      "title": "Data Type",
      "description": "The column data type the class is for (FOR TYPE).",
      "type": "string"
    },
    "default": {
      "title": "Default",
      "description": "The class is the default for its data type and index method.",
      "type": "boolean"
    },
    "family": {
      "title": "Operator Family",
      "description": "The operator family the class belongs to, schema-qualified. Without it, PostgreSQL makes a family with the name of the class.\n",
      "type": "string"
    },
    "storage": {
      "title": "Storage Type",
      "description": "The data type stored in the index (STORAGE), when it is not the column data type.\n",
      "type": "string"
    },
    "operators": {
      "title": "Operators",
      "description": "The operators of the class.",
      "type": "array",
      "items": {
        "title": "Operator Class Operator",
        "description": "An operator of an operator class or family: OPERATOR strategy name (left, right) [FOR ORDER BY sort_family].\n",
        "type": "object",
        "properties": {
          "strategy": {
            "title": "Strategy Number",
            "description": "The index method's strategy number for the operator.",
            "type": "integer",
            "minimum": 1
          },
          "name": {
            "title": "Operator",
            "description": "The operator, schema-qualified when it is not in pg_catalog.",
            "type": "string"
          },
          "arguments": {
            "title": "Operand Types",
            "description": "The left and right operand types.",
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 2,
            "maxItems": 2
          },
          "order_by": {
            "title": "Sort Family",
            "description": "The btree operator family that sorts the result of an ordering operator (FOR ORDER BY). Without it, the operator is a search operator.\n",
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "strategy",
          "name"
        ]
      }
    },
    "functions": {
      "title": "Support Functions",
      "description": "The support functions of the class.",
      "type": "array",
      "items": {
        "title": "Operator Class Function",
        "description": "A support function of an operator class or family: FUNCTION number (left, right) function(arguments).\n",
        "type": "object",
        "properties": {
          "support": {
            "title": "Support Number",
            "description": "The index method's support function number.",
            "type": "integer",
            "minimum": 1
          },
          "types": {
            "title": "Operand Types",
            "description": "The left and right operand types the function is for.",
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 2,
            "maxItems": 2
          },
          "function": {
            "title": "Function",
            "description": "The function and its argument types.",
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "support",
          "function"
        ]
      }
    },
    "comment": {
      "title": "Comment",
      "description": "An optional comment about the operator class.",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "required": [
    "name",
    "schema",
    "method",
    "data_type"
  ]
}