Schema Migration Generator

Generate database migration code from a current and a desired schema. Supports Drizzle, Prisma, Knex and plain SQL.

Pay by wallet (x402) AI-generated schema-migration-generate

Example

Example answer
{
  "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

FieldTypeRequiredWhat it is
ormstringNodrizzle/prisma/knex/raw
current_schemastringNo—
desired_schemastringYes—

Output fields

How reliably each field appears in a successful answer.

FieldTypeAppears
ormstringAlways (present in every successful answer)
migration_upstringAlways (present in every successful answer)
migration_downstringAlways (present in every successful answer)
breaking_changesarrayAlways (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
  }'

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