table_alter
Change the columns or name of a data table. One call is one atomic step: every operation applies, or none does.
Operations:
{"op":"add_column","name":"currency","type":"text","nullable":true,"default":"'USD'","comment":"..."} — existing rows get the default. Re-running a completed add returns applied: [] with note already_exists.
{"op":"rename_column","from":"memo","to":"bank_memo"} — data and indexes are kept.
{"op":"set_default","name":"status","default":"'paid'"} (null removes it)
{"op":"set_nullable","name":"status","nullable":false}
{"op":"drop_column","name":"amount_tol"} — DESTRUCTIVE
{"op":"alter_type","name":"bank_total","type":"bigint","using":"bank_total::bigint"} — DESTRUCTIVE; refused with VALUE_WOULD_TRUNCATE when any value would change
{"op":"rename_table","to":"new_name"} — DESTRUCTIVE
Types: text, integer, bigint, numeric, boolean, timestamptz, date, uuid, jsonb. id, created_at and updated_at are protected. Destructive operations need a person: the call returns code APPROVAL_REQUIRED with approval.requestId, nothing is applied (not even the other operations in the call), and a card appears in the chat. There is no confirm flag. Do not retry; the person's decision starts your next turn. In a chat, a default on a table above 250,000 rows returns job.jobId; poll table_change_status. Outside a chat it runs inline. Failures return success:false, code, operationIndex and the database message unchanged.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"operations": "<operations>"
},
"name": "table_alter"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tableId | No | Table ID. Supply exactly one of tableId or tableName. | |
| tableName | No | Exact, case-sensitive accessible table name or SQL table slug; preferred when known. table, name and table_name are accepted aliases. Supply exactly one of tableName or tableId. | |
| operations | Yes | Array of operations (a JSON string is also accepted). Example: [{"op":"add_column","name":"settlement_date","type":"date"}] | |
| approvalRequestId | No | Optional. The requestId of an earlier APPROVAL_REQUIRED result, to read its outcome. It never approves anything: only a person can, on the card in the chat. |