- Home
- Skills
- Data & Databases
- Schema Migration Generator
Works with the AI tools you already use
Schema Migration Generator
Automated SQL migration generator for diffing schemas and creating safe, dialect-specific up/down scripts.
$9.99
Schema Migration Generator
Example session with this skill installed
Generate a PostgreSQL migration for Flyway that adds a 'refund_amount' decimal column and a 'refunded_at' timestamp to the 'orders' table. The new columns should allow nulls.
- Read your context and instructions
- Compiled the schema migration generator
I have generated the PostgreSQL migration scripts for the requested changes to the orders table. The scripts follow Flyway naming conventions and include safety notes for the new columns.
Migration Scripts
File: V20231027101500__add_order_refunds.sql (Up)
-- Up Migration
-- Risk: Low. Adding nullable columns is a metadata-only operation in modern Postgres.
ALTER TABLE orders
ADD COLUMN refund_amount DECIMAL(12, 2) DEFAULT NULL,
ADD COLUMN refunded_at TIMESTAMP WITH TIME ZONE DEFAULT NULL;
-- Create index for performance on refund queries
CREATE INDEX CONCURRENTLY idx_orders_refunded_at ON orders(refunded_at) WHERE refunded_at IS NOT NULL;
File: U20231027101500__add_order_refunds.sql (Down)
-- Down Migration
DROP INDEX CONCURRENTLY IF EXISTS idx_orders_refunded_at;
ALTER TABLE orders
DROP COLUMN IF EXISTS refund_amount,
DROP COLUMN IF EXISTS refunded_at;
Safety Guidance
- Operation: Adding nullable columns.
- Risk: Low. No table rewrite required for PG 11+.
Optimization: I added CONCURRENTLY to the index creation to prevent locking the orders table during the build. Note that concurrent index builds cannot run inside a transaction block in some runners.
Next steps
- Verify the
DECIMALprecision meets your specific currency requirements. - Run the migration against a staging environment with a representative data set.
- Ensure your application code is deployed to handle the new nullable fields before applying the migration.
Connects securely to your tools. The creator never sees your data.
About this skill
Database schema changes often result in manual, error-prone SQL scripts or unreliable ORM auto-generation. This skill automates the diffing process between schema states to produce production-ready migration files with safety guards.
What it does
- Schema Diffing compares DDL or ORM exports to detect structural changes.
- Migration Generation outputs ordered up and down scripts for major SQL dialects.
- Change Detection handles tables, columns, indexes, constraints, and probable renames.
- Safety Auditing flags risky operations like table rewrites or locking index builds.
- Multi-Format Export supports Flyway, Liquibase, golang-migrate, and Rails/Knex naming.
How it works
- Provide a current schema dump and a desired-state schema file.
- Specify the target dialect (PostgreSQL, MySQL, SQLite, or SQL Server).
- Select the output style for file naming conventions.
- Review the generated SQL and the safety guidance for zero-downtime deployment.
Frameworks & tools
This skill works with PostgreSQL, MySQL, MariaDB, SQLite, and SQL Server. It integrates with migration runners like Flyway, Liquibase, golang-migrate, Rails, and Knex.
Why this beats prompting it yourself
Generic LLMs often hallucinate syntax or miss subtle dialect-specific constraints like index locking behavior. This skill follows a structured diffing logic to ensure every ADD, ALTER, and DROP is accounted for while explicitly warning about operations that could cause production downtime.
Use cases
- Generating Flyway scripts from a local PG dump and a new
schema.sql. - Auditing a proposed migration for potential table-locking risks.
- Creating idempotent down-migration scripts for emergency rollbacks.
- Converting an ORM-generated schema into standard SQL migration files.
Known limitations
Does not support NoSQL databases. Requires raw SQL DDL as input for the most accurate diffing. Renames are detected by probability and may require manual confirmation.
How to use
Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean today
- Passed all security checks, Safe to install