Manage the database schema: read current schema, apply changes, preview changes, and audit migration history.
Actions:
- "get": Get the current schema (tables, columns, indexes) and api_base
- "apply": Apply a declarative schema. Diffs against current and runs the safe DDL.
- "dry_run": Preview the SQL that "apply" would run, without executing
- "list_migrations": List applied migrations (most recent first)
Parameters by action:
get: { app_id, action: "get" }
apply: { app_id, action: "apply", schema, name? }
dry_run: { app_id, action: "dry_run", schema }
list_migrations: { app_id, action: "list_migrations" }
Schema example:
{
tables: {
posts: {
columns: {
id: { type: "uuid", primaryKey: true, default: "gen_random_uuid()" },
title: { type: "text", nullable: false },
author_id: { type: "uuid", references: { table: "users", column: "id", onDelete: "CASCADE" } },
created_at: { type: "timestamptz", default: "now()" }
}
}
}
}
Idempotency: "apply" is safe to call multiple times. If the schema is already up-to-date, returns "Schema is up to date".
Destructive operations: Require explicit opt-in via the _drop (table-level) or _dropColumns (column-level) fields.
Common errors:
- VALIDATION_INVALID_SCHEMA: schema format does not match the DSL
- STATE_PREREQUISITE_MISSING: add _drop / _dropColumns to authorize destructive ops
- QUOTA_TABLE_LIMIT: max 50 tables per app
- RESOURCE_NOT_FOUND: app_id does not exist