{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gmr.github.io/pglifecycle/schemata/transforms.json",
  "title": "Transforms",
  "description": "Specifies the transforms for the data types in a schema\n",
  "type": "object",
  "properties": {
    "schema": {
      "title": "Schema",
      "description": "The schema of the data types in this file.",
      "type": "string"
    },
    "transforms": {
      "title": "Transforms",
      "type": "array",
      "items": {
        "title": "Transform",
        "description": "Defines a transform, which converts a data type to and from the form a procedural language uses. A transform has no owner. The project keeps it in the schema of its data type. When the data type is built-in, the project keeps it in the first schema that its functions name, or in public.\n",
        "type": "object",
        "properties": {
          "schema": {
            "title": "Schema",
            "type": "string"
          },
          "type": {
            "title": "Data Type",
            "description": "The data type the transform converts.",
            "type": "string"
          },
          "language": {
            "title": "Language",
            "description": "The procedural language the transform is for.",
            "type": "string"
          },
          "from_sql": {
            "title": "From SQL Function",
            "description": "The function, with its argument types, that converts the data type to the form the language uses. It takes one argument of type internal and returns internal.\n",
            "type": "string"
          },
          "to_sql": {
            "title": "To SQL Function",
            "description": "The function, with its argument types, that converts from the form the language uses to the data type. It takes one argument of type internal and returns the data type.\n",
            "type": "string"
          },
          "comment": {
            "title": "Comment",
            "description": "An optional comment about the transform",
            "type": "string"
          },
          "dependencies": {
            "title": "Dependencies",
            "description": "Objects this object depends on, for the cases the dependency graph cannot infer: an ordering the topological sort would otherwise get wrong, such as a table that a view reads, or a function that a SQL-standard function body calls. A foreign key needs no entry: the build adds each foreign key after all tables.\nEach entry names an object as `schema.name`, or unqualified for a schemaless type. A function or aggregate carries the argument types of one overload (`test.f(integer)`, or `test.agg(*)` for an aggregate with no arguments), and an operator its left and right argument types (`test.=~=(integer, integer)`), since overloads share a name, and a cast its types (`(int4 AS timestamp)`). The argument types compare as PostgreSQL resolves them. A bare function, aggregate or operator name is correct only when one overload has it.\n",
            "type": "object",
            "properties": {
              "aggregates": {
                "description": "The aggregates this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "collations": {
                "description": "The collations this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "domains": {
                "description": "The domains this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "event_triggers": {
                "description": "The event triggers this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "extensions": {
                "description": "The extensions this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "foreign_data_wrappers": {
                "description": "The foreign data wrappers this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "functions": {
                "description": "The functions this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "languages": {
                "description": "The languages this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "materialized_views": {
                "description": "The materialized views this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "operators": {
                "description": "The operators this object depends on, each with its left and right argument types (`test.=~=(integer, integer)`, or `test.!!!(NONE, integer)` for a prefix operator).\n",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "publications": {
                "description": "The publications this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "sequences": {
                "description": "The sequences this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "servers": {
                "description": "The servers this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "subscriptions": {
                "description": "The subscriptions this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "tables": {
                "description": "The tables this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "types": {
                "description": "The types this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "user_mappings": {
                "description": "The user mappings this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "users": {
                "description": "The users this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "views": {
                "description": "The views this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false,
        "required": [
          "type",
          "language"
        ],
        "anyOf": [
          {
            "required": [
              "from_sql"
            ]
          },
          {
            "required": [
              "to_sql"
            ]
          }
        ]
      }
    }
  },
  "required": [
    "schema",
    "transforms"
  ],
  "additionalProperties": false
}