pg_manage_schema
Streamline PostgreSQL schema management by retrieving schema details, creating or altering tables, and managing ENUM types efficiently.
Instructions
Manage PostgreSQL schema - get schema info, create/alter tables, manage enums. Examples: operation="get_info" for table lists, operation="create_table" with tableName and columns, operation="get_enums" to list enums, operation="create_enum" with enumName and values
Input Schema
Name | Required | Description | Default |
---|---|---|---|
columns | No | Column definitions (required for create_table) | |
connectionString | No | PostgreSQL connection string (optional) | |
enumName | No | ENUM name (optional for get_enums to filter, required for create_enum) | |
ifNotExists | No | Include IF NOT EXISTS clause (for create_enum) | |
operation | Yes | Operation: get_info (schema/table info), create_table (new table), alter_table (modify table), get_enums (list ENUMs), create_enum (new ENUM) | |
operations | No | Alter operations (required for alter_table) | |
schema | No | Schema name (defaults to public) | |
tableName | No | Table name (optional for get_info to get specific table info, required for create_table/alter_table) | |
values | No | ENUM values (required for create_enum) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"columns": {
"description": "Column definitions (required for create_table)",
"items": {
"additionalProperties": false,
"properties": {
"default": {
"description": "Default value expression",
"type": "string"
},
"name": {
"type": "string"
},
"nullable": {
"type": "boolean"
},
"type": {
"description": "PostgreSQL data type",
"type": "string"
}
},
"required": [
"name",
"type"
],
"type": "object"
},
"type": "array"
},
"connectionString": {
"description": "PostgreSQL connection string (optional)",
"type": "string"
},
"enumName": {
"description": "ENUM name (optional for get_enums to filter, required for create_enum)",
"type": "string"
},
"ifNotExists": {
"description": "Include IF NOT EXISTS clause (for create_enum)",
"type": "boolean"
},
"operation": {
"description": "Operation: get_info (schema/table info), create_table (new table), alter_table (modify table), get_enums (list ENUMs), create_enum (new ENUM)",
"enum": [
"get_info",
"create_table",
"alter_table",
"get_enums",
"create_enum"
],
"type": "string"
},
"operations": {
"description": "Alter operations (required for alter_table)",
"items": {
"additionalProperties": false,
"properties": {
"columnName": {
"type": "string"
},
"dataType": {
"description": "PostgreSQL data type (for add/alter)",
"type": "string"
},
"default": {
"description": "Default value expression (for add/alter)",
"type": "string"
},
"nullable": {
"description": "Whether the column can be NULL (for add/alter)",
"type": "boolean"
},
"type": {
"enum": [
"add",
"alter",
"drop"
],
"type": "string"
}
},
"required": [
"type",
"columnName"
],
"type": "object"
},
"type": "array"
},
"schema": {
"description": "Schema name (defaults to public)",
"type": "string"
},
"tableName": {
"description": "Table name (optional for get_info to get specific table info, required for create_table/alter_table)",
"type": "string"
},
"values": {
"description": "ENUM values (required for create_enum)",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"operation"
],
"type": "object"
}