From c10dabfc3c9082487621fd19b23d15042b4fce00 Mon Sep 17 00:00:00 2001 From: Alexis Rico Date: Tue, 2 Jan 2024 19:15:14 +0100 Subject: [PATCH] Fix pgroll migration definition (#216) - Split `PgRollMigration` so that we can properly use it in the frontend - Fix operation keys not being included in the schema --- schema.json | 181 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 132 insertions(+), 49 deletions(-) diff --git a/schema.json b/schema.json index cd988fa..ba3fa1b 100644 --- a/schema.json +++ b/schema.json @@ -312,6 +312,137 @@ "required": ["identity", "table"], "type": "object" }, + "PgRollOperation": { + "anyOf": [ + { + "type": "object", + "description": "Add column operation", + "additionalProperties": false, + "properties": { + "add_column": { + "$ref": "#/$defs/OpAddColumn" + } + }, + "required": ["add_column"] + }, + { + "type": "object", + "description": "Alter column operation", + "additionalProperties": false, + "properties": { + "alter_column": { + "$ref": "#/$defs/OpAlterColumn" + } + }, + "required": ["alter_column"] + }, + { + "type": "object", + "description": "Create index operation", + "additionalProperties": false, + "properties": { + "create_index": { + "$ref": "#/$defs/OpCreateIndex" + } + }, + "required": ["create_index"] + }, + { + "type": "object", + "description": "Create table operation", + "additionalProperties": false, + "properties": { + "create_table": { + "$ref": "#/$defs/OpCreateTable" + } + }, + "required": ["create_table"] + }, + { + "type": "object", + "description": "Drop column operation", + "additionalProperties": false, + "properties": { + "drop_column": { + "$ref": "#/$defs/OpDropColumn" + } + }, + "required": ["drop_column"] + }, + { + "type": "object", + "description": "Drop constraint operation", + "additionalProperties": false, + "properties": { + "drop_constraint": { + "$ref": "#/$defs/OpDropConstraint" + } + }, + "required": ["drop_constraint"] + }, + { + "type": "object", + "description": "Drop index operation", + "additionalProperties": false, + "properties": { + "drop_index": { + "$ref": "#/$defs/OpDropIndex" + } + }, + "required": ["drop_index"] + }, + { + "type": "object", + "description": "Drop table operation", + "additionalProperties": false, + "properties": { + "drop_table": { + "$ref": "#/$defs/OpDropTable" + } + }, + "required": ["drop_table"] + }, + { + "type": "object", + "description": "Raw SQL operation", + "additionalProperties": false, + "properties": { + "raw_sql": { + "$ref": "#/$defs/OpRawSQL" + } + }, + "required": ["raw_sql"] + }, + { + "type": "object", + "description": "Rename table operation", + "additionalProperties": false, + "properties": { + "rename_table": { + "$ref": "#/$defs/OpRenameTable" + } + }, + "required": ["rename_table"] + }, + { + "type": "object", + "description": "Set replica identity operation", + "additionalProperties": false, + "properties": { + "set_replica_identity": { + "$ref": "#/$defs/OpSetReplicaIdentity" + } + }, + "required": ["set_replica_identity"] + } + ] + }, + "PgRollOperations": { + "items": { + "$ref": "#/$defs/PgRollOperation" + }, + "type": "array" + }, "PgRollMigration": { "additionalProperties": false, "description": "PgRoll migration definition", @@ -321,55 +452,7 @@ "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" + "$ref": "#/$defs/PgRollOperations" } }, "required": ["name", "operations"],