Skip to main content
Back to Dev generators

Dev

Mock Database Migration Generator

Used by developers, writers, and creators worldwide.

The mock database migration generator creates ready-to-run SQL scripts with paired UP and DOWN blocks for five common schema operations: create table, add column, drop column, rename column, and add index. Pick your SQL dialect — PostgreSQL, MySQL, or SQLite — and the output reflects dialect-specific syntax for data types, quoting, and auto-increment conventions. Developers use this to bootstrap migration files, build documentation examples with real SQL, or verify that a migration runner handles rollbacks correctly. Instead of looking up whether PostgreSQL uses SERIAL or IDENTITY, or whether SQLite supports DROP COLUMN, you get a correct starting point in seconds.

Loading usage…

Free forever — no account required

How to use

  1. Choose your options above
  2. Click Generate
  3. Copy your result

Detailed instructions

  1. Enter the exact table name you want to target in the Table Name field (e.g., 'orders' or 'user_profiles').
  2. Select the migration type from the dropdown — choose create-table, add-column, drop-column, rename-column, or create-index.
  3. Pick the SQL dialect that matches your database: PostgreSQL, MySQL, or SQLite.
  4. Click Generate to produce the migration script, then review the UP and DOWN sections for correctness.
  5. Copy the output and paste it into your migration file, adjusting column types or constraints to match your real schema.

Use Cases

  • Seeding a Flyway migrations folder with correct PostgreSQL CREATE TABLE and DROP TABLE rollback scripts
  • Scaffolding a Knex.js ADD COLUMN migration for MySQL before writing the corresponding Sequelize model
  • Testing CI rollback logic by running generated DROP COLUMN UP/DOWN pairs against a staging database
  • Generating SQLite ALTER TABLE scripts for a React Native app's local schema versioning
  • Producing accurate SQL examples for internal Notion docs covering team schema change conventions

Tips

  • When using create-table, immediately generate a matching create-index script for the same table to scaffold both files at once.
  • For Flyway projects, generate the DOWN script as a separate undo migration file prefixed with U instead of V.
  • SQLite's DROP COLUMN output should be tested against your SQLite version — versions below 3.35.0 require a table-rebuild workaround instead.
  • Use the rename-column operation to generate the syntax reference, then manually add a data migration step if the column holds values that need transforming.
  • MySQL users: the generated scripts assume InnoDB; add ENGINE=InnoDB explicitly if your database defaults to MyISAM to ensure transaction support.
  • Generate the same operation in all three dialects and diff the output to build a personal reference for cross-database syntax differences.

FAQ

what's the difference between a migration up and down script

The UP script applies a schema change — creating a table, adding a column, or building an index. The DOWN script reverses it exactly: dropping the table, removing the column, or deleting the index. Keeping them paired means you can roll back to any previous schema state without writing manual SQL on the fly.

can I paste these sql migration scripts directly into flyway or knex

For Flyway and Liquibase, yes — both accept raw SQL files. Name the file using the expected prefix convention (V3__create_users_table.sql for Flyway) and drop it into your migrations folder. For Knex.js, run knex migrate:make, then paste the UP body into exports.up wrapped in knex.raw() and the DOWN body into exports.down.

does sqlite support all the same operations as postgresql or mysql

No. SQLite's ALTER TABLE support is limited — DROP COLUMN wasn't supported before SQLite 3.35.0, and RENAME COLUMN arrived in 3.25.0. The generator produces standard SQLite syntax, so check your SQLite version before running drop or rename scripts in production.