{"uid":"cap_goEFWma3biqscTHvNZx1G","slug":"api-strale-io-60d08e4b","name":"Database Schema Migration Code Generator","description":"Generate database migration code from current→desired schema description. Supports Drizzle, Prisma, Knex, and raw SQL.","url":"https://api.strale.io/x402/schema-migration-generate","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET","HEAD","DELETE"],"type":"string"},"queryParams":{"type":"object","required":["desired_schema"],"properties":{"orm":{"type":"string","description":"drizzle/prisma/knex/raw"},"current_schema":{"type":"string"},"desired_schema":{"type":"string"}}}},"additionalProperties":false}}},"responseSchema":null,"example":{"request":{"orm":"prisma","current_schema":"table users { id Int primary key, name String, email String }","desired_schema":"table users { id Int primary key, name String, email String, createdAt DateTime } table roles { id Int primary key, name String }"},"response":{"orm":"prisma","_meta":{"payment":{"method":"x402","price_usd":0.054000000000000006,"settlement_id":"0x6febf36ce6ce6400a67fc97f6ad36d5b1c3f2222cb4fab96c266d1a27890d21e"},"capability":"schema-migration-generate","latency_ms":3086,"provenance":{"source":"claude-haiku","fetched_at":"2026-06-13T04:23:27.983Z"}},"up_sql":"ALTER TABLE \"users\" ADD COLUMN \"createdAt\" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;\n\nCREATE TABLE \"roles\" (\n    \"id\" SERIAL NOT NULL PRIMARY KEY,\n    \"name\" TEXT NOT NULL\n);","down_sql":"ALTER TABLE \"users\" DROP COLUMN \"createdAt\";\n\nDROP TABLE \"roles\";","warnings":["The 'createdAt' column is set to DEFAULT CURRENT_TIMESTAMP - existing rows will have current migration timestamp, not actual creation time","Consider backfilling 'createdAt' with accurate historical data if available"],"migration":"-- CreateTable roles\nCREATE TABLE \"roles\" (\n    \"id\" SERIAL NOT NULL PRIMARY KEY,\n    \"name\" TEXT NOT NULL\n);\n\n-- AlterTable users\nALTER TABLE \"users\" ADD COLUMN \"createdAt\" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;","breaking_changes":["New required column 'createdAt' added to users table - existing application code must handle this column","New roles table introduced - related features should be implemented to utilize this table"]}},"exampleRequest":{"orm":"prisma","current_schema":"table users { id Int primary key, name String, email String }","desired_schema":"table users { id Int primary key, name String, email String, createdAt DateTime } table roles { id Int primary key, name String }"},"tags":["x402"],"displayCostAmount":"0.054001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"settled","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.054001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.054","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.054","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_nxmm1EZGvLLS22KXyH6wk","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.054","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Generates database migration code from a current schema to a desired schema, supporting Drizzle, Prisma, Knex, and raw SQL","exampleAgentPrompt":"Generate a Prisma migration from my current schema (users table with id, name, email) to a desired schema that also adds a createdAt timestamp column and a roles table with id and name.","exampleUseCases":[{"title":"Automated database schema upgrades","prompt":"We're refactoring our payments system and need to add a transactions table with fields for amount, status, and timestamp. Can you generate the Drizzle migration code to transform our current schema into this new structure?"},{"title":"Multi-ORM migration code generation","prompt":"Our team uses Knex for database migrations. I want to rename the user_email column to email_address and add a verified_at timestamp column. Generate the migration code that will handle this safely."},{"title":"Compliance schema transformation automation","prompt":"We need to split our users table into users and user_profiles tables for GDPR compliance, moving sensitive personal data to user_profiles. Can you create the raw SQL migration code to handle this schema transformation?"}],"resultDescription":"Returns generated migration code in the specified ORM format (Drizzle, Prisma, Knex, or raw SQL) that transforms the current schema into the desired schema, ready to apply to a database.","failureModes":["Missing desired_schema parameter returns an error","Invalid ORM type value returns unsupported ORM error","Malformed or unparseable schema description may result in incomplete or incorrect migration code","Conflicting schema definitions may produce ambiguous migrations"],"whenToPreferThis":"Use this endpoint when you need to automatically generate migration code between two database schema states without writing migration files by hand, especially when working with popular ORMs like Prisma or Drizzle or needing raw SQL migrations.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-13T13:07:01.561Z","isFirstParty":false}