Schema Migration Generator
Generate database migration code from a current and a desired schema. Supports Drizzle, Prisma, Knex and plain SQL.
schema-migration-generate Example
{
"orm": "raw",
"up_sql": "ALTER TABLE users ADD COLUMN email VARCHAR(255);",
"down_sql": "ALTER TABLE users DROP COLUMN email;",
"warnings": [
"New column 'email' is nullable by default. Existing rows will have NULL values for email.",
"If email should be unique or NOT NULL, consider adding constraints after migration and populating existing rows.",
"Application code expecting email field may receive NULL values from existing records."
],
"migration": "ALTER TABLE users ADD COLUMN email VARCHAR(255);",
"breaking_changes": []
} Inputs
| Field | Type | Required | What it is |
|---|---|---|---|
orm | string | No | drizzle/prisma/knex/raw |
current_schema | string | No | — |
desired_schema | string | Yes | — |
Output fields
How reliably each field appears in a successful answer.
| Field | Type | Appears |
|---|---|---|
orm | string | Always (present in every successful answer) |
migration_up | string | Always (present in every successful answer) |
migration_down | string | Always (present in every successful answer) |
breaking_changes | array | Always (present in every successful answer) |
How to call it
The same tool through each route. MCP clients reach it through Strale’s server at https://api.strale.io/mcp; the call below is what the agent sends.
# Needs an API key. max_price_cents caps what this call may cost.
curl -X POST https://api.strale.io/v1/do \
-H "Authorization: Bearer $STRALE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"capability_slug": "schema-migration-generate",
"inputs": {
"current_schema": "users(id INT PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE, created_at TIMESTAMP DEFAULT NOW())",
"desired_schema": "users(id INT PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE, age INT, created_at TIMESTAMP DEFAULT NOW())"
},
"max_price_cents": 5
}' {
"tool": "strale_execute",
"arguments": {
"slug": "schema-migration-generate",
"inputs": {
"current_schema": "users(id INT PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE, created_at TIMESTAMP DEFAULT NOW())",
"desired_schema": "users(id INT PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE, age INT, created_at TIMESTAMP DEFAULT NOW())"
},
"max_price_cents": 5
}
} import { Strale } from "straleio";
const strale = new Strale({ apiKey: process.env.STRALE_API_KEY! });
const result = await strale.do({
capability_slug: "schema-migration-generate",
inputs: {
"current_schema": "users(id INT PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE, created_at TIMESTAMP DEFAULT NOW())",
"desired_schema": "users(id INT PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE, age INT, created_at TIMESTAMP DEFAULT NOW())"
},
max_price_cents: 5,
}); import os
from straleio import Strale, DoRequest
strale = Strale(api_key=os.environ["STRALE_API_KEY"])
result = strale.do(DoRequest(
capability_slug="schema-migration-generate",
inputs={
"current_schema": "users(id INT PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE, created_at TIMESTAMP DEFAULT NOW())",
"desired_schema": "users(id INT PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE, age INT, created_at TIMESTAMP DEFAULT NOW())",
},
max_price_cents=5,
)) # No account. The first request answers 402 with the price in USDC;
# an x402 client pays it from your wallet and repeats the request.
curl -i 'https://api.strale.io/x402/v2/schema-migration-generate?current_schema=users%28id+INT+PRIMARY+KEY%2C+name+TEXT+NOT+NULL%2C+email+TEXT+UNIQUE%2C+created_at+TIMESTAMP+DEFAULT+NOW%28%29%29&desired_schema=users%28id+INT+PRIMARY+KEY%2C+name+TEXT+NOT+NULL%2C+email+TEXT+UNIQUE%2C+age+INT%2C+created_at+TIMESTAMP+DEFAULT+NOW%28%29%29' Limitations
Destructive migrations require review before use
AI-generated migrations — destructive operations (DROP COLUMN, type changes) should be verified before running on production data
What to do instead: Always review generated migrations in a staging environment and add explicit backfill steps for data transformations
Output size cap per call
Structured output is limited to about 2000 output tokens per call; requests exceeding this limit are refused rather than returned truncated. Requests with large results can exceed this limit, and repeating the same request does not help.
What to do instead: Provide a smaller schema per call
Related tools
- Agent Trace Analysis €0.20
- API Docs Generator €0.20
- API Mock Responses €0.05
- Changelog Generator €0.03
- Code Converter €0.05
- Commit Message Generator €0.05