Group
  • Database

    Set up real database migrations

    Replaces manual schema edits and auto-sync with versioned, runnable migrations that work the same everywhere.

    • Plan & validate
    • Ship faster
    • Intermediate
    • Cursor
    • General

Free Prompt

Set up a proper migration system for my database. Check what I'm using now: an ORM with auto-sync, manual SQL edits against the live database, or nothing (the schema just exists because the code expects it). Implement: versioned migration files that run in order, each with an up and a down path; a tracking table recording which migrations have run, so running them twice is a no-op and new environments catch up automatically; migrations wired into my deploy process so schema changes apply before the new code starts; and my current schema captured as the baseline migration so a fresh database (new developer, staging, disaster recovery) can be built from nothing. Disable any ORM auto-sync or 'alter tables to match models' behavior in production; it's how columns get dropped silently. Write migrations to be deploy-safe: adding columns with defaults, creating indexes concurrently where the database supports it, and avoiding table locks on large tables. Never have a migration destroy data without me explicitly approving it in the file. Deliver: the migration setup, the baseline, the deploy integration, and a verification: build a fresh database from scratch using only the migrations, and roll back the last one to confirm the down path works.

What This Does / How This Helps

Replaces manual schema edits and ORM auto-sync with versioned migrations that run identically on every environment. Hand-edited schemas drift. Local has one shape, staging another, production a third, and deploys fail because the code expects a column that only exists on your laptop. Auto-sync is worse: it silently alters production tables to match the models, and dropping a field from a model can drop the column and everything in it. You get a baseline that rebuilds the whole schema from nothing, which doubles as your disaster recovery answer for 'how do I recreate the database?'

Want to skip doing this by hand?

Fortivibe audits your app for all of the areas these prompts cover (and more).

See What We Check

Related Prompts