mirror of
https://github.com/xataio/pgroll.git
synced 2024-09-11 13:55:28 +03:00
All structs matched well except for `PrimaryKey` which we mapped differently, I've refactored it to `Pk` as it doesn't seem to support different names for go and JSON --------- Signed-off-by: Alexis Rico <sferadev@gmail.com> Co-authored-by: Andrew Farries <andyrb@gmail.com>
408 lines
11 KiB
JSON
408 lines
11 KiB
JSON
{
|
|
"$id": "https://raw.githubusercontent.com/xataio/pgroll/main/schema.json",
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"title": "JSON Schema for pgroll migrations",
|
|
"description": "This JSON schema defines the structure and properties of pgroll migrations.",
|
|
"allOf": [{ "$ref": "#/$defs/PgRollMigration" }],
|
|
"$defs": {
|
|
"CheckConstraint": {
|
|
"additionalProperties": false,
|
|
"description": "Check constraint definition",
|
|
"properties": {
|
|
"constraint": {
|
|
"description": "Constraint expression",
|
|
"type": "string"
|
|
},
|
|
"name": {
|
|
"description": "Name of check constraint",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["constraint", "name"],
|
|
"type": "object"
|
|
},
|
|
"Column": {
|
|
"additionalProperties": false,
|
|
"description": "Column definition",
|
|
"properties": {
|
|
"check": {
|
|
"$ref": "#/$defs/CheckConstraint",
|
|
"description": "Check constraint for the column"
|
|
},
|
|
"default": {
|
|
"description": "Default value for the column",
|
|
"type": "string"
|
|
},
|
|
"name": {
|
|
"description": "Name of the column",
|
|
"type": "string"
|
|
},
|
|
"nullable": {
|
|
"description": "Indicates if the column is nullable",
|
|
"type": "boolean"
|
|
},
|
|
"pk": {
|
|
"description": "Indicates if the column is part of the primary key",
|
|
"type": "boolean"
|
|
},
|
|
"references": {
|
|
"$ref": "#/$defs/ForeignKeyReference",
|
|
"description": "Foreign key constraint for the column"
|
|
},
|
|
"type": {
|
|
"description": "Postgres type of the column",
|
|
"type": "string"
|
|
},
|
|
"unique": {
|
|
"description": "Indicates if the column values must be unique",
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"required": ["name", "nullable", "pk", "type", "unique"],
|
|
"type": "object"
|
|
},
|
|
"ForeignKeyReference": {
|
|
"additionalProperties": false,
|
|
"description": "Foreign key reference definition",
|
|
"properties": {
|
|
"column": {
|
|
"description": "Name of the referenced column",
|
|
"type": "string"
|
|
},
|
|
"name": {
|
|
"description": "Name of the foreign key constraint",
|
|
"type": "string"
|
|
},
|
|
"table": {
|
|
"description": "Name of the referenced table",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["column", "name", "table"],
|
|
"type": "object"
|
|
},
|
|
"OpAddColumn": {
|
|
"additionalProperties": false,
|
|
"description": "Add column operation",
|
|
"properties": {
|
|
"column": {
|
|
"$ref": "#/$defs/Column",
|
|
"description": "Column to add"
|
|
},
|
|
"table": {
|
|
"description": "Name of the table",
|
|
"type": "string"
|
|
},
|
|
"up": {
|
|
"description": "SQL expression for up migration",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["column", "table"],
|
|
"type": "object"
|
|
},
|
|
"OpAlterColumn": {
|
|
"additionalProperties": false,
|
|
"description": "Alter column operation",
|
|
"properties": {
|
|
"check": {
|
|
"$ref": "#/$defs/CheckConstraint",
|
|
"description": "Add check constraint to the column"
|
|
},
|
|
"column": {
|
|
"description": "Name of the column",
|
|
"type": "string"
|
|
},
|
|
"down": {
|
|
"description": "SQL expression for down migration",
|
|
"type": "string"
|
|
},
|
|
"name": {
|
|
"description": "New name of the column (for rename column operation)",
|
|
"type": "string"
|
|
},
|
|
"nullable": {
|
|
"description": "Indicates if the column is nullable (for add not null constraint operation)",
|
|
"type": "boolean"
|
|
},
|
|
"references": {
|
|
"$ref": "#/$defs/ForeignKeyReference",
|
|
"description": "Add foreign key constraint to the column"
|
|
},
|
|
"table": {
|
|
"description": "Name of the table",
|
|
"type": "string"
|
|
},
|
|
"type": {
|
|
"description": "New type of the column (for change type operation)",
|
|
"type": "string"
|
|
},
|
|
"unique": {
|
|
"$ref": "#/$defs/UniqueConstraint",
|
|
"description": "Add unique constraint to the column"
|
|
},
|
|
"up": {
|
|
"description": "SQL expression for up migration",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["column", "down", "name", "table", "type", "up"],
|
|
"type": "object"
|
|
},
|
|
"OpCreateIndex": {
|
|
"additionalProperties": false,
|
|
"description": "Create index operation",
|
|
"properties": {
|
|
"columns": {
|
|
"description": "Names of columns on which to define the index",
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"type": "array"
|
|
},
|
|
"name": {
|
|
"description": "Index name",
|
|
"type": "string"
|
|
},
|
|
"table": {
|
|
"description": "Name of table on which to define the index",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["columns", "name", "table"],
|
|
"type": "object"
|
|
},
|
|
"OpCreateTable": {
|
|
"additionalProperties": false,
|
|
"description": "Create table operation",
|
|
"properties": {
|
|
"columns": {
|
|
"items": {
|
|
"$ref": "#/$defs/Column",
|
|
"description": "Columns to add to the table"
|
|
},
|
|
"type": "array"
|
|
},
|
|
"name": {
|
|
"description": "Name of the table",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["columns", "name"],
|
|
"type": "object"
|
|
},
|
|
"OpDropColumn": {
|
|
"additionalProperties": false,
|
|
"description": "Drop column operation",
|
|
"properties": {
|
|
"column": {
|
|
"description": "Name of the column",
|
|
"type": "string"
|
|
},
|
|
"down": {
|
|
"description": "SQL expression for down migration",
|
|
"type": "string"
|
|
},
|
|
"table": {
|
|
"description": "Name of the table",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["column", "table"],
|
|
"type": "object"
|
|
},
|
|
"OpDropConstraint": {
|
|
"additionalProperties": false,
|
|
"description": "Drop constraint operation",
|
|
"properties": {
|
|
"column": {
|
|
"description": "Name of the column",
|
|
"type": "string"
|
|
},
|
|
"down": {
|
|
"description": "SQL expression for down migration",
|
|
"type": "string"
|
|
},
|
|
"name": {
|
|
"description": "Name of the constraint",
|
|
"type": "string"
|
|
},
|
|
"table": {
|
|
"description": "Name of the table",
|
|
"type": "string"
|
|
},
|
|
"up": {
|
|
"description": "SQL expression for up migration",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["column", "down", "name", "table", "up"],
|
|
"type": "object"
|
|
},
|
|
"OpDropIndex": {
|
|
"additionalProperties": false,
|
|
"description": "Drop index operation",
|
|
"properties": {
|
|
"name": {
|
|
"description": "Index name",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["name"],
|
|
"type": "object"
|
|
},
|
|
"OpDropTable": {
|
|
"additionalProperties": false,
|
|
"description": "Drop table operation",
|
|
"properties": {
|
|
"name": {
|
|
"description": "Name of the table",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["name"],
|
|
"type": "object"
|
|
},
|
|
"OpRawSQL": {
|
|
"additionalProperties": false,
|
|
"description": "Raw SQL operation",
|
|
"properties": {
|
|
"down": {
|
|
"default": "",
|
|
"description": "SQL expression for down migration",
|
|
"type": "string"
|
|
},
|
|
"up": {
|
|
"description": "SQL expression for up migration",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["up"],
|
|
"type": "object"
|
|
},
|
|
"OpRenameTable": {
|
|
"additionalProperties": false,
|
|
"description": "Rename table operation",
|
|
"properties": {
|
|
"from": {
|
|
"description": "Old name of the table",
|
|
"type": "string"
|
|
},
|
|
"to": {
|
|
"description": "New name of the table",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["from", "to"],
|
|
"type": "object"
|
|
},
|
|
"OpSetReplicaIdentity": {
|
|
"additionalProperties": false,
|
|
"description": "Set replica identity operation",
|
|
"properties": {
|
|
"identity": {
|
|
"$ref": "#/$defs/ReplicaIdentity",
|
|
"description": "Replica identity to set"
|
|
},
|
|
"table": {
|
|
"description": "Name of the table",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["identity", "table"],
|
|
"type": "object"
|
|
},
|
|
"PgRollMigration": {
|
|
"additionalProperties": false,
|
|
"description": "PgRoll migration definition",
|
|
"properties": {
|
|
"name": {
|
|
"description": "Name of the migration",
|
|
"type": "string"
|
|
},
|
|
"operations": {
|
|
"items": {
|
|
"anyOf": [
|
|
{
|
|
"$ref": "#/$defs/OpAddColumn",
|
|
"description": "Add column operation"
|
|
},
|
|
{
|
|
"$ref": "#/$defs/OpAlterColumn",
|
|
"description": "Alter column operation"
|
|
},
|
|
{
|
|
"$ref": "#/$defs/OpCreateIndex",
|
|
"description": "Create index operation"
|
|
},
|
|
{
|
|
"$ref": "#/$defs/OpCreateTable",
|
|
"description": "Create table operation"
|
|
},
|
|
{
|
|
"$ref": "#/$defs/OpDropColumn",
|
|
"description": "Drop column operation"
|
|
},
|
|
{
|
|
"$ref": "#/$defs/OpDropConstraint",
|
|
"description": "Drop constraint operation"
|
|
},
|
|
{
|
|
"$ref": "#/$defs/OpDropIndex",
|
|
"description": "Drop index operation"
|
|
},
|
|
{
|
|
"$ref": "#/$defs/OpDropTable",
|
|
"description": "Drop table operation"
|
|
},
|
|
{
|
|
"$ref": "#/$defs/OpRawSQL",
|
|
"description": "Raw SQL operation"
|
|
},
|
|
{
|
|
"$ref": "#/$defs/OpRenameTable",
|
|
"description": "Rename table operation"
|
|
},
|
|
{
|
|
"$ref": "#/$defs/OpSetReplicaIdentity",
|
|
"description": "Set replica identity operation"
|
|
}
|
|
]
|
|
},
|
|
"type": "array"
|
|
}
|
|
},
|
|
"required": ["name", "operations"],
|
|
"type": "object"
|
|
},
|
|
"ReplicaIdentity": {
|
|
"additionalProperties": false,
|
|
"description": "Replica identity definition",
|
|
"properties": {
|
|
"index": {
|
|
"description": "Name of the index to use as replica identity",
|
|
"type": "string"
|
|
},
|
|
"type": {
|
|
"description": "Type of replica identity",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["index", "type"],
|
|
"type": "object"
|
|
},
|
|
"UniqueConstraint": {
|
|
"additionalProperties": false,
|
|
"description": "Unique constraint definition",
|
|
"properties": {
|
|
"name": {
|
|
"description": "Name of unique constraint",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": ["name"],
|
|
"type": "object"
|
|
}
|
|
}
|
|
}
|