{
  "$defs": {
    "ptah.embedded": {
      "additionalProperties": false,
      "description": "Controls how an embedded Go field contributes schema objects.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "patternProperties": {
            "^platform\\.[A-Za-z0-9_]+\\.[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)*$": {
              "description": "Dialect-specific platform override.",
              "type": "string"
            }
          },
          "properties": {
            "comment": {
              "description": "Generated column comment.",
              "type": "string"
            },
            "field": {
              "description": "Generated relation field name.",
              "type": "string"
            },
            "mode": {
              "description": "Embedding mode: inline, json, or relation.",
              "type": "string"
            },
            "name": {
              "description": "Column name for json embedding.",
              "type": "string"
            },
            "nullable": {
              "description": "Marks generated embedded columns nullable.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string",
              "x-ptah-bare-boolean": true
            },
            "on_delete": {
              "description": "Generated foreign key ON DELETE action.",
              "type": "string"
            },
            "on_update": {
              "description": "Generated foreign key ON UPDATE action.",
              "type": "string"
            },
            "prefix": {
              "description": "Column prefix for inline embedded fields.",
              "type": "string"
            },
            "ref": {
              "description": "Relation target in table(column) form.",
              "type": "string"
            },
            "type": {
              "description": "Column type for json embedding.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "directive": {
          "const": "ptah:embedded"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.composite": {
      "additionalProperties": false,
      "description": "Declares a PostgreSQL composite type.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "comment": {
              "description": "Composite type comment.",
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "fields": {
              "description": "Comma-separated name:type field list.",
              "type": "string"
            },
            "name": {
              "description": "Composite type name.",
              "type": "string"
            },
            "schema": {
              "description": "Target schema/namespace.",
              "type": "string"
            }
          },
          "required": [
            "fields",
            "name"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:composite"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.constraint": {
      "additionalProperties": false,
      "description": "Declares a table constraint.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "check": {
              "description": "CHECK expression.",
              "type": "string"
            },
            "columns": {
              "description": "Comma-separated local columns.",
              "type": "string"
            },
            "comment": {
              "description": "Constraint comment.",
              "type": "string"
            },
            "condition": {
              "description": "Constraint WHERE condition.",
              "type": "string"
            },
            "elements": {
              "description": "EXCLUDE constraint elements.",
              "type": "string"
            },
            "foreign_column": {
              "description": "Single referenced column for FOREIGN KEY constraints.",
              "type": "string"
            },
            "foreign_columns": {
              "description": "Comma-separated referenced columns for composite FOREIGN KEY constraints.",
              "type": "string"
            },
            "foreign_table": {
              "description": "Referenced table for FOREIGN KEY constraints.",
              "type": "string"
            },
            "include": {
              "description": "Comma-separated PostgreSQL INCLUDE columns for covering UNIQUE constraints.",
              "type": "string"
            },
            "name": {
              "description": "Constraint name.",
              "type": "string"
            },
            "nulls_distinct": {
              "description": "Controls NULLS DISTINCT behavior where supported.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "on_delete": {
              "description": "Foreign key ON DELETE action.",
              "type": "string"
            },
            "on_update": {
              "description": "Foreign key ON UPDATE action.",
              "type": "string"
            },
            "table": {
              "description": "Explicit target table.",
              "type": "string"
            },
            "type": {
              "description": "Constraint type: CHECK, UNIQUE, PRIMARY KEY, FOREIGN KEY, or EXCLUDE.",
              "type": "string"
            },
            "using": {
              "description": "EXCLUDE index method.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:constraint"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.continuousaggregate": {
      "additionalProperties": false,
      "description": "Declares a TimescaleDB continuous aggregate: a materialized view over a hypertable the extension keeps up to date.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "body": {
              "description": "The SELECT the aggregate materializes.",
              "type": "string"
            },
            "comment": {
              "description": "Continuous aggregate comment.",
              "type": "string"
            },
            "materialized_only": {
              "description": "Read only materialized data, rather than combining it with the rows since the last refresh.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "name": {
              "description": "Aggregate name, which is also the view name.",
              "type": "string"
            },
            "schema": {
              "description": "Schema holding the aggregate.",
              "type": "string"
            }
          },
          "required": [
            "body",
            "name"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:continuousaggregate"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.data": {
      "additionalProperties": false,
      "description": "Declares external reference/seed row data for a table.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "file": {
              "description": "Path to the YAML row-data file, relative to the Go source file.",
              "type": "string"
            },
            "key": {
              "description": "Comma-separated key column(s) forming each row's identity.",
              "type": "string"
            },
            "schema": {
              "description": "Database schema the table belongs to.",
              "type": "string"
            },
            "table": {
              "description": "Target table the rows belong to.",
              "type": "string"
            }
          },
          "required": [
            "file",
            "key",
            "table"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:data"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.domain": {
      "additionalProperties": false,
      "description": "Declares a PostgreSQL domain type.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "check": {
              "description": "CHECK constraint expression (uses VALUE).",
              "type": "string"
            },
            "comment": {
              "description": "Domain comment.",
              "type": "string"
            },
            "default": {
              "description": "Literal DEFAULT value.",
              "type": "string"
            },
            "default_expr": {
              "description": "DEFAULT expression.",
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "name": {
              "description": "Domain name.",
              "type": "string"
            },
            "not_null": {
              "description": "Marks the domain NOT NULL.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "schema": {
              "description": "Target schema/namespace.",
              "type": "string"
            },
            "type": {
              "description": "Underlying base data type.",
              "type": "string"
            }
          },
          "required": [
            "name",
            "type"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:domain"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.enum": {
      "additionalProperties": false,
      "description": "Declares a reusable enum type.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "name": {
              "description": "Enum type name.",
              "type": "string"
            },
            "values": {
              "description": "Comma-separated enum values.",
              "type": "string"
            }
          },
          "required": [
            "name",
            "values"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:enum"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.extendedproperty": {
      "additionalProperties": false,
      "description": "Declares a SQL Server extended property on a schema, a table, or a column.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "column": {
              "description": "Column the property is on. Requires table.",
              "type": "string"
            },
            "comment": {
              "description": "Extended property comment.",
              "type": "string"
            },
            "name": {
              "description": "Property name. MS_Description is refused: it is the object comment, which Ptah already manages.",
              "type": "string"
            },
            "schema": {
              "description": "Schema the property is on, or that owns the addressed table. Omit for a database-scoped property.",
              "type": "string"
            },
            "table": {
              "description": "Table the property is on. Requires schema; omit for a schema-scoped property.",
              "type": "string"
            },
            "value": {
              "description": "The value, written back as an N'' literal.",
              "type": "string"
            }
          },
          "required": [
            "name",
            "value"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:extendedproperty"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.extension": {
      "additionalProperties": false,
      "description": "Declares a PostgreSQL extension.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "comment": {
              "description": "Extension comment.",
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "if_not_exists": {
              "description": "Adds IF NOT EXISTS where supported.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "name": {
              "description": "Extension name.",
              "type": "string"
            },
            "schema": {
              "description": "PostgreSQL installation schema.",
              "type": "string"
            },
            "version": {
              "description": "Extension version.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:extension"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.field": {
      "additionalProperties": false,
      "description": "Maps a Go struct field to a database column.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "patternProperties": {
            "^platform\\.[A-Za-z0-9_]+\\.[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)*$": {
              "description": "Dialect-specific platform override.",
              "type": "string"
            }
          },
          "properties": {
            "api_expose": {
              "description": "Whether this column reaches an exported API contract: none, read, write or read-write. It declares a contract shape and is not access control.",
              "type": "string"
            },
            "api_name": {
              "description": "Name this column carries in an exported API schema, when that differs from the column name.",
              "type": "string"
            },
            "api_type": {
              "description": "Type the API export projects this column as, named in Ptah's own type vocabulary.",
              "type": "string"
            },
            "auto_increment": {
              "description": "Marks the column as auto-incrementing.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string",
              "x-ptah-bare-boolean": true
            },
            "check": {
              "description": "Column CHECK expression.",
              "type": "string"
            },
            "check_name": {
              "description": "Explicit CHECK constraint name.",
              "type": "string"
            },
            "comment": {
              "description": "Column comment.",
              "type": "string"
            },
            "default": {
              "description": "Literal column default.",
              "type": "string"
            },
            "default_expr": {
              "description": "SQL default expression.",
              "type": "string"
            },
            "enum": {
              "description": "Comma-separated enum values.",
              "type": "string"
            },
            "foreign": {
              "description": "Foreign key reference in table(column) form.",
              "type": "string"
            },
            "foreign_key_name": {
              "description": "Explicit foreign key constraint name.",
              "type": "string"
            },
            "generated": {
              "description": "Generated column expression.",
              "type": "string"
            },
            "generated_kind": {
              "description": "Generated column kind, such as STORED or VIRTUAL.",
              "type": "string"
            },
            "graphql_name": {
              "description": "Name this column carries in the GraphQL export only, overriding api_name there.",
              "type": "string"
            },
            "identity_generation": {
              "description": "SQL identity generation mode.",
              "type": "string"
            },
            "identity_increment": {
              "description": "SQL identity increment value.",
              "type": "string"
            },
            "identity_options": {
              "description": "Raw SQL identity options.",
              "type": "string"
            },
            "identity_start": {
              "description": "SQL identity start value.",
              "type": "string"
            },
            "name": {
              "description": "Column name.",
              "type": "string"
            },
            "not_null": {
              "description": "Marks the column NOT NULL.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string",
              "x-ptah-bare-boolean": true
            },
            "on_delete": {
              "description": "Foreign key ON DELETE action.",
              "type": "string"
            },
            "on_update": {
              "description": "Foreign key ON UPDATE action.",
              "type": "string"
            },
            "openapi_name": {
              "description": "Name this column carries in the OpenAPI export only, overriding api_name there.",
              "type": "string"
            },
            "primary": {
              "description": "Marks the column as part of the primary key.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string",
              "x-ptah-bare-boolean": true
            },
            "proto_name": {
              "description": "Name this column carries in the Protobuf export only, overriding api_name there. It is the wire identity, so changing it retires a field number.",
              "type": "string"
            },
            "stored": {
              "description": "Shortcut controlling generated column storage.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "type": {
              "description": "Database column type.",
              "type": "string"
            },
            "unique": {
              "description": "Adds a single-column unique constraint.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string",
              "x-ptah-bare-boolean": true
            },
            "unique_expr": {
              "description": "Uniqueness over an expression. Not implemented: rendering refuses a column that declares it.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:field"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.function": {
      "additionalProperties": false,
      "description": "Declares a database function.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "body": {
              "description": "Function body SQL.",
              "type": "string"
            },
            "comment": {
              "description": "Function comment.",
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "language": {
              "description": "Function language.",
              "type": "string"
            },
            "name": {
              "description": "Function name.",
              "type": "string"
            },
            "params": {
              "description": "Function parameter list.",
              "type": "string"
            },
            "returns": {
              "description": "Return type.",
              "type": "string"
            },
            "schema": {
              "description": "Target schema/namespace.",
              "type": "string"
            },
            "security": {
              "description": "Security mode, such as DEFINER.",
              "type": "string"
            },
            "settings": {
              "description": "Routine configuration settings, `name=value`, separated by `;`; pin `search_path` on a DEFINER routine.",
              "type": "string"
            },
            "volatility": {
              "description": "Volatility class.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:function"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.grant": {
      "additionalProperties": false,
      "description": "Declares database grants.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "comment": {
              "description": "Grant comment.",
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "grant_option": {
              "description": "Alias for with_option.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string",
              "x-ptah-alias-for": "with_option"
            },
            "on_schema": {
              "description": "Target schema.",
              "type": "string"
            },
            "on_sequence": {
              "description": "Target sequence.",
              "type": "string"
            },
            "on_table": {
              "description": "Target table.",
              "type": "string"
            },
            "privilege": {
              "description": "Privilege or comma-separated privileges.",
              "type": "string"
            },
            "privileges": {
              "description": "Alias for privilege.",
              "type": "string",
              "x-ptah-alias-for": "privilege"
            },
            "role": {
              "description": "Target role.",
              "type": "string"
            },
            "with_option": {
              "description": "Adds WITH GRANT OPTION where supported.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            }
          },
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:grant"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.hypertable": {
      "additionalProperties": false,
      "description": "Declares a TimescaleDB hypertable: a table partitioned on a range dimension.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "chunk_interval": {
              "description": "Width of one chunk, spelled the way PostgreSQL spells an interval. Omit to take TimescaleDB's default.",
              "type": "string"
            },
            "column": {
              "description": "Range dimension: the column chunks are cut on.",
              "type": "string"
            },
            "comment": {
              "description": "Hypertable comment.",
              "type": "string"
            },
            "if_not_exists": {
              "description": "Skip a table that is already a hypertable instead of failing.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "table": {
              "description": "Table to partition, optionally schema-qualified.",
              "type": "string"
            }
          },
          "required": [
            "column",
            "table"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:hypertable"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.index": {
      "additionalProperties": false,
      "description": "Declares an index for a table.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "columns": {
              "description": "Legacy synonym for fields.",
              "type": "string",
              "x-ptah-alias-for": "fields"
            },
            "comment": {
              "description": "Index comment.",
              "type": "string"
            },
            "condition": {
              "description": "Partial index condition.",
              "type": "string"
            },
            "fields": {
              "description": "Comma-separated Go field or column names.",
              "type": "string"
            },
            "granularity": {
              "description": "ClickHouse data-skipping index granularity.",
              "type": "string"
            },
            "include": {
              "description": "Comma-separated INCLUDE columns for covering indexes (PostgreSQL: default/BTREE/GIST, plus SPGIST on 14+; YugabyteDB: default/LSM, with BTREE as the default-LSM alias; Spanner PostgreSQL dialect: default only).",
              "type": "string"
            },
            "name": {
              "description": "Index name.",
              "type": "string"
            },
            "nulls_distinct": {
              "description": "Controls NULLS DISTINCT behavior where supported.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "ops": {
              "description": "PostgreSQL operator class.",
              "type": "string"
            },
            "table": {
              "description": "Explicit target table.",
              "type": "string"
            },
            "type": {
              "description": "Index type or method.",
              "type": "string"
            },
            "unique": {
              "description": "Creates a unique index.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string",
              "x-ptah-bare-boolean": true
            },
            "where": {
              "description": "Atlas-style partial index condition alias.",
              "type": "string",
              "x-ptah-alias-for": "condition"
            }
          },
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:index"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.matview": {
      "additionalProperties": false,
      "description": "Declares a materialized view.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "body": {
              "description": "Materialized view SELECT body.",
              "type": "string"
            },
            "comment": {
              "description": "Materialized view comment.",
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "name": {
              "description": "Materialized view name.",
              "type": "string"
            },
            "refresh": {
              "description": "ClickHouse refresh schedule, as ClickHouse spells it: `every 1 hour`, `after 30 minute`, `every 1 day offset 2 hour`. Omitted leaves the view maintained by inserts into its source.",
              "type": "string"
            },
            "refresh_strategy": {
              "description": "Retired: refused when the annotation is parsed, on every dialect. Ptah does not refresh materialized views: one is populated when it is created, a changed definition is reconciled as DROP and CREATE, and it goes stale only when its source data changes, which schema reconciliation cannot observe. Remove the attribute and refresh from your own scheduler.",
              "not": {},
              "x-ptah-retired": "Ptah does not refresh materialized views: one is populated when it is created, a changed definition is reconciled as DROP and CREATE, and it goes stale only when its source data changes, which schema reconciliation cannot observe. Remove the attribute and refresh from your own scheduler"
            },
            "schema": {
              "description": "Target schema/namespace.",
              "type": "string"
            }
          },
          "required": [
            "body",
            "name"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:matview"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.procedure": {
      "additionalProperties": false,
      "description": "Declares a stored procedure: a routine that returns nothing and is invoked with CALL.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "body": {
              "description": "Procedure body SQL.",
              "type": "string"
            },
            "comment": {
              "description": "Procedure comment.",
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "language": {
              "description": "Procedure language.",
              "type": "string"
            },
            "name": {
              "description": "Procedure name.",
              "type": "string"
            },
            "params": {
              "description": "Procedure parameter list.",
              "type": "string"
            },
            "schema": {
              "description": "Target schema/namespace.",
              "type": "string"
            },
            "security": {
              "description": "Security mode, such as DEFINER.",
              "type": "string"
            },
            "volatility": {
              "description": "Volatility class.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:procedure"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.range": {
      "additionalProperties": false,
      "description": "Declares a PostgreSQL range type.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "canonical": {
              "description": "Canonicalization function.",
              "type": "string"
            },
            "collation": {
              "description": "Collation for the subtype.",
              "type": "string"
            },
            "comment": {
              "description": "Range type comment.",
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "name": {
              "description": "Range type name.",
              "type": "string"
            },
            "schema": {
              "description": "Target schema/namespace.",
              "type": "string"
            },
            "subtype": {
              "description": "Element subtype the range is built over.",
              "type": "string"
            },
            "subtype_diff": {
              "description": "Subtype difference function.",
              "type": "string"
            },
            "subtype_opclass": {
              "description": "Operator class for the subtype.",
              "type": "string"
            }
          },
          "required": [
            "name",
            "subtype"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:range"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.rls.enable": {
      "additionalProperties": false,
      "description": "Enables row-level security on a table.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "comment": {
              "description": "RLS enablement comment.",
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "table": {
              "description": "Target table.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:rls:enable"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.rls.policy": {
      "additionalProperties": false,
      "description": "Declares a row-level security policy.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "comment": {
              "description": "Policy comment.",
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "for": {
              "description": "Policy command, such as ALL or SELECT.",
              "type": "string"
            },
            "name": {
              "description": "Policy name.",
              "type": "string"
            },
            "table": {
              "description": "Target table.",
              "type": "string"
            },
            "to": {
              "description": "Comma-separated roles.",
              "type": "string"
            },
            "using": {
              "description": "USING expression.",
              "type": "string"
            },
            "with_check": {
              "description": "WITH CHECK expression.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:rls:policy"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.role": {
      "additionalProperties": false,
      "description": "Declares a database role.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "comment": {
              "description": "Role comment.",
              "type": "string"
            },
            "create_db": {
              "description": "Alias for createdb.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string",
              "x-ptah-alias-for": "createdb"
            },
            "create_role": {
              "description": "Alias for createrole.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string",
              "x-ptah-alias-for": "createrole"
            },
            "createdb": {
              "description": "Allows database creation.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "createrole": {
              "description": "Allows role creation.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "inherit": {
              "description": "Controls role inheritance; defaults to true.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "login": {
              "description": "Creates the role with LOGIN.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "name": {
              "description": "Role name.",
              "type": "string"
            },
            "password": {
              "description": "Role password.",
              "type": "string"
            },
            "replication": {
              "description": "Allows replication.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "superuser": {
              "description": "Creates the role as SUPERUSER.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            }
          },
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:role"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.schema": {
      "additionalProperties": false,
      "description": "Declares a database schema or namespace.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "comment": {
              "description": "Schema comment.",
              "type": "string"
            },
            "name": {
              "description": "Schema name.",
              "type": "string"
            }
          },
          "required": [
            "name"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:schema"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.sequence": {
      "additionalProperties": false,
      "description": "Declares a standalone PostgreSQL sequence.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "as": {
              "description": "Underlying integer type, such as bigint.",
              "type": "string"
            },
            "cache": {
              "description": "CACHE size.",
              "type": "string"
            },
            "comment": {
              "description": "Sequence comment.",
              "type": "string"
            },
            "cycle": {
              "description": "Enables CYCLE wrap-around.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "if_not_exists": {
              "description": "Adds IF NOT EXISTS where supported.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "increment": {
              "description": "INCREMENT BY value; must be non-zero.",
              "type": "string"
            },
            "maxvalue": {
              "description": "MAXVALUE bound.",
              "type": "string"
            },
            "minvalue": {
              "description": "MINVALUE bound.",
              "type": "string"
            },
            "name": {
              "description": "Sequence name.",
              "type": "string"
            },
            "owned_by": {
              "description": "Owning table.column association (OWNED BY).",
              "type": "string"
            },
            "schema": {
              "description": "Target schema/namespace.",
              "type": "string"
            },
            "start": {
              "description": "START WITH value.",
              "type": "string"
            }
          },
          "required": [
            "name"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:sequence"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.synonym": {
      "additionalProperties": false,
      "description": "Declares a SQL Server synonym, an alias for another object.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "comment": {
              "description": "Synonym comment.",
              "type": "string"
            },
            "name": {
              "description": "Synonym name, the alias being declared.",
              "type": "string"
            },
            "schema": {
              "description": "Schema the alias lives in.",
              "type": "string"
            },
            "target": {
              "description": "Object the alias stands for, as one to four dot-separated parts.",
              "type": "string"
            }
          },
          "required": [
            "name",
            "target"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:synonym"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.table": {
      "additionalProperties": false,
      "description": "Maps a Go struct to a database table.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "patternProperties": {
            "^platform\\.[A-Za-z0-9_]+\\.[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)*$": {
              "description": "Dialect-specific platform override.",
              "type": "string"
            }
          },
          "properties": {
            "api_name": {
              "description": "Name this table carries in an exported API schema, when that differs from the table name.",
              "type": "string"
            },
            "checks": {
              "description": "Comma-separated table-level check expressions.",
              "type": "string"
            },
            "comment": {
              "description": "Table comment.",
              "type": "string"
            },
            "custom": {
              "description": "Raw custom CREATE TABLE SQL.",
              "type": "string"
            },
            "engine": {
              "description": "MySQL/MariaDB table engine shortcut.",
              "type": "string"
            },
            "graphql_name": {
              "description": "Name this table carries in the GraphQL export only, overriding api_name there.",
              "type": "string"
            },
            "name": {
              "description": "Table name.",
              "type": "string"
            },
            "openapi_name": {
              "description": "Name this table carries in the OpenAPI export only, overriding api_name there.",
              "type": "string"
            },
            "primary_key": {
              "description": "Comma-separated primary key columns.",
              "type": "string"
            },
            "proto_name": {
              "description": "Name this table carries in the Protobuf export only, overriding api_name there. It is the message identity, so changing it retires the old message.",
              "type": "string"
            },
            "schema": {
              "description": "Database schema name.",
              "type": "string"
            },
            "ttl_delete_batch_size": {
              "description": "CockroachDB row-level TTL: rows deleted per batch; at least 1.",
              "type": "string"
            },
            "ttl_delete_rate_limit": {
              "description": "CockroachDB row-level TTL: rows deleted per second; at least 1.",
              "type": "string"
            },
            "ttl_disable_changefeed_replication": {
              "description": "CockroachDB row-level TTL: omits the job's deletes from changefeeds. `true`/`false`.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "ttl_expiration_expression": {
              "description": "CockroachDB row-level TTL: SQL expression whose value is when a row expires. Enables the TTL.",
              "type": "string"
            },
            "ttl_expire_after": {
              "description": "CockroachDB row-level TTL: interval after a row is written at which it expires, such as `3 days`. Enables the TTL.",
              "type": "string"
            },
            "ttl_job_cron": {
              "description": "CockroachDB row-level TTL: cron schedule for the deletion job.",
              "type": "string"
            },
            "ttl_label_metrics": {
              "description": "CockroachDB row-level TTL: labels the job's metrics with the table name. `true`/`false`.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "ttl_pause": {
              "description": "CockroachDB row-level TTL: pauses the deletion job without removing the policy. `true`/`false`.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            },
            "ttl_row_stats_poll_interval": {
              "description": "CockroachDB row-level TTL: how often the job refreshes its row-count estimate, such as `10m`. Truncated to whole seconds; a value below one second is refused.",
              "type": "string"
            },
            "ttl_select_batch_size": {
              "description": "CockroachDB row-level TTL: rows selected per batch; at least 1.",
              "type": "string"
            },
            "ttl_select_rate_limit": {
              "description": "CockroachDB row-level TTL: rows selected per second; at least 1.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:table"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.trigger": {
      "additionalProperties": false,
      "description": "Declares a database trigger.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "body": {
              "description": "Trigger body SQL.",
              "type": "string"
            },
            "comment": {
              "description": "Trigger comment.",
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "event": {
              "description": "Trigger event, such as INSERT or UPDATE.",
              "type": "string"
            },
            "for": {
              "description": "Trigger granularity; defaults to ROW.",
              "type": "string"
            },
            "name": {
              "description": "Trigger name.",
              "type": "string"
            },
            "table": {
              "description": "Target table.",
              "type": "string"
            },
            "timing": {
              "description": "Trigger timing, such as BEFORE or AFTER.",
              "type": "string"
            }
          },
          "required": [
            "body",
            "event",
            "name",
            "table",
            "timing"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:trigger"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    },
    "ptah.schema.view": {
      "additionalProperties": false,
      "description": "Declares a database view.",
      "properties": {
        "attributes": {
          "additionalProperties": false,
          "properties": {
            "body": {
              "description": "View SELECT body.",
              "type": "string"
            },
            "comment": {
              "description": "View comment.",
              "type": "string"
            },
            "dialects": {
              "description": "Comma-separated target dialects this object belongs to. Omitted means every dialect; a target the scope excludes leaves the object out of its desired state entirely, so nothing compares or plans it there.",
              "type": "string"
            },
            "name": {
              "description": "View name.",
              "type": "string"
            },
            "schema": {
              "description": "Target schema/namespace.",
              "type": "string"
            },
            "with_check": {
              "description": "Controls WITH CHECK OPTION where supported.",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            }
          },
          "required": [
            "body",
            "name"
          ],
          "type": "object"
        },
        "directive": {
          "const": "ptah:schema:view"
        }
      },
      "required": [
        "directive",
        "attributes"
      ],
      "type": "object"
    }
  },
  "$id": "https://docs.ptah.run/ptah-annotations.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "Schema for parsed //ptah Go annotation directives.",
  "oneOf": [
    {
      "$ref": "#/$defs/ptah.schema.field"
    },
    {
      "$ref": "#/$defs/ptah.embedded"
    },
    {
      "$ref": "#/$defs/ptah.schema.index"
    },
    {
      "$ref": "#/$defs/ptah.schema.table"
    },
    {
      "$ref": "#/$defs/ptah.schema.schema"
    },
    {
      "$ref": "#/$defs/ptah.schema.constraint"
    },
    {
      "$ref": "#/$defs/ptah.schema.enum"
    },
    {
      "$ref": "#/$defs/ptah.schema.extension"
    },
    {
      "$ref": "#/$defs/ptah.schema.function"
    },
    {
      "$ref": "#/$defs/ptah.schema.procedure"
    },
    {
      "$ref": "#/$defs/ptah.schema.sequence"
    },
    {
      "$ref": "#/$defs/ptah.schema.domain"
    },
    {
      "$ref": "#/$defs/ptah.schema.composite"
    },
    {
      "$ref": "#/$defs/ptah.schema.range"
    },
    {
      "$ref": "#/$defs/ptah.schema.view"
    },
    {
      "$ref": "#/$defs/ptah.schema.matview"
    },
    {
      "$ref": "#/$defs/ptah.schema.continuousaggregate"
    },
    {
      "$ref": "#/$defs/ptah.schema.hypertable"
    },
    {
      "$ref": "#/$defs/ptah.schema.synonym"
    },
    {
      "$ref": "#/$defs/ptah.schema.extendedproperty"
    },
    {
      "$ref": "#/$defs/ptah.schema.trigger"
    },
    {
      "$ref": "#/$defs/ptah.schema.rls.policy"
    },
    {
      "$ref": "#/$defs/ptah.schema.rls.enable"
    },
    {
      "$ref": "#/$defs/ptah.schema.role"
    },
    {
      "$ref": "#/$defs/ptah.schema.grant"
    },
    {
      "$ref": "#/$defs/ptah.schema.data"
    }
  ],
  "title": "Ptah Go Annotation Directives"
}
