$ recombobulate _
home / tips / generate-database-migration-files-from-a-schema-description
0

Generate Database Migration Files from a Schema Description

bagwaa @bagwaa · Mar 25, 2026 · Workflows
generate-database-migration-files-from-a-schema-description

Writing database migrations by hand is fiddly — foreign keys, indexes, enum types, nullable columns in the right order. Describe the change you want and Claude will write the migration in seconds.

Write a Laravel migration that adds a `status` column (enum: draft, published, archived)
to the `posts` table, a nullable `published_at` timestamp, and a composite index on
`(status, published_at)`.

Claude knows the conventions of your framework, so the output is idiomatic code — not a generic SQL dump. This works for Laravel, Rails, Django, Doctrine, and more. Just specify which one you're using.

For more complex changes, describe the before and after state:

My `users` table has a single `name` column. Split it into `first_name` and `last_name`.
Write the migration to add the new columns, backfill them by splitting on the first space,
then drop the old column — in the correct order for a safe rollout.

Claude will handle the backfill logic and column ordering, which is easy to get wrong manually. It'll also generate the down() method so your migration is fully reversible.

You can go further and ask Claude to generate multiple migration files for a full feature — it'll figure out the dependency order and name them with appropriate timestamps.

Always review migrations before running them in production — Claude is fast, but your data is irreplaceable.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Scan Pending Changes for Security Issues with /security-review

The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.

bagwaa @bagwaa · 1 hour ago
0
Run Setup Scripts on Every Session with the SessionStart Hook

The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.

bagwaa @bagwaa · 1 hour ago
0
Write Property-Based Tests with fast-check and Claude

Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.

bagwaa @bagwaa · 2 hours ago