{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gmr.github.io/pglifecycle/schemata/collation.json",
  "title": "Collation",
  "description": "A collation is a schema object that provides the locale rules used when sorting and comparing text.\n",
  "type": "object",
  "properties": {
    "name": {
      "title": "Name",
      "description": "The name of the collation function to create.",
      "type": "string"
    },
    "schema": {
      "title": "Schema",
      "description": "The schema to create the collation function in.",
      "type": "string"
    },
    "owner": {
      "title": "Owner",
      "description": "The role that owns the collation function.",
      "type": "string"
    },
    "sql": {
      "title": "SQL",
      "description": "Raw SQL for the object",
      "type": "string"
    },
    "locale": {
      "title": "Locale",
      "description": "This is a shortcut for setting lc_collate and lc_ctype at once. If you specify this, you cannot specify either of those parameters.\n",
      "type": "string"
    },
    "lc_collate": {
      "title": "Locale Collation",
      "description": "Use the specified operating system locale for the LC_COLLATE locale category.\n",
      "type": "string"
    },
    "lc_ctype": {
      "title": "Locale CType",
      "description": "Use the specified operating system locale for the LC_CTYPE locale category.\n",
      "type": "string"
    },
    "provider": {
      "title": "Locale Provider",
      "description": "Specifies the provider to use for locale services associated with this collation. Possible values are: icu, libc. libc is the default. The available choices depend on the operating system and build options.\n",
      "enum": [
        "icu",
        "libc"
      ]
    },
    "version": {
      "title": "Collation Version",
      "description": "Specifies the version string to store with the collation. Normally this should be omitted, which causes the version to be computed from the actual version of the collation as provided by the operating system.\n",
      "type": "string"
    },
    "rules": {
      "title": "ICU Rules",
      "description": "Tailoring rules for an ICU collation, in ICU's rule syntax (PostgreSQL 16 and later).\n",
      "type": "string"
    },
    "deterministic": {
      "title": "Deterministic Comparisons",
      "description": "Specifies whether the collation should use deterministic comparisons.\n",
      "type": "boolean",
      "default": true
    },
    "copy_from": {
      "title": "Source Collation",
      "description": "Copy the collation from a pre-existing collation",
      "type": "string"
    },
    "comment": {
      "title": "Comment",
      "description": "An optional comment about the collation.",
      "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 foreign key between tables or an inheritance parent.\nEach entry names an object as `schema.name`, or unqualified for a schemaless type. A function or aggregate carries its argument signature (`test.f(integer)`) and a cast its types (`(int4 AS timestamp)`), since the name alone is ambiguous.\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"
          }
        },
        "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
    }
  },
  "required": [
    "schema",
    "name",
    "owner"
  ],
  "oneOf": [
    {
      "required": [
        "sql"
      ]
    },
    {
      "required": [
        "copy_from"
      ]
    },
    {
      "anyOf": [
        {
          "required": [
            "locale"
          ]
        },
        {
          "required": [
            "lc_collate"
          ]
        },
        {
          "required": [
            "lc_ctype"
          ]
        }
      ]
    }
  ]
}