Ask Autohand Code to inspect current migrations, add a safe schema change, and update API code that depends on it.
Create schema changes with seed data and rollback notes
Data Delivery and operations Implementation Code
autohand -p "Add the migration for this data model and update the related API"
A migration, indexes, seed data when needed, and validation notes.
Write database migrations with Autohand Code is a database workflow that creates schema changes, indexes, backfills, seed data, API updates, and verification SQL for the affected app paths. ### At a glance | Question | Answer | | --- | --- | | Best for | D1, SQLite, Postgres, or app schema changes that runtime code will read immediately | | Primary inputs | Data model, expected query paths, and uniqueness rules; Existing rows that need backfill or default values; Target database environment and deployment constraints | | Autohand Code returns | A migration, indexes, seed data when needed, and validation notes. | | Avoid when | the data model is speculative and no query path needs it yet | ### How Autohand Code handles this workflow 1. Reads previous migrations and current data-access code. 2. Chooses compatible column names, defaults, constraints, and indexes. 3. Backfills safe values without breaking existing rows. 4. Adds verification SQL that proves the app can read the new shape. ### Best inputs - Data model, expected query paths, and uniqueness rules - Existing rows that need backfill or default values - Target database environment and deployment constraints ### Strong prompt autohand -p "Add the migration for this data model and update the related API" ### Autohand Code CLI options - Run `autohand -p "Add the migration for this data model and update the related API"` for one schema change. - Use `--dry-run` or `--patch` when SQL needs DBA or reviewer approval before it is applied. - Set the target workspace with `--path` and keep environment-specific settings in `/settings` or `~/.autohand/config.*`. ### Review before accepting A good migration includes explicit indexes, safe defaults, rollback or mitigation notes, and a query that proves the result. ### Source and validation signals Autohand AI maintains this workflow as first-party product guidance for Autohand Code. Use the [Autohand CLI Playbook](https://github.com/autohandai/code-cli/blob/main/docs/AUTOHAND_PLAYBOOK.md), [CLI reference](/docs/working-with-autohand-code/cli-reference.html), and [configuration reference](https://github.com/autohandai/code-cli/blob/main/docs/config-reference.md) when choosing between interactive mode, command mode, auto-mode, feature-enabled /goal, /settings, skills, MCP, and permission settings. The related resources below link to product docs and tutorials for the workflow, and the final answer should name repository-specific files, commands, outputs, or docs that a reviewer can verify. ### Frequently asked questions ### What is Write database migrations with Autohand Code? Write database migrations with Autohand Code is a database workflow that creates schema changes, indexes, backfills, seed data, API updates, and verification SQL for the affected app paths. ### When should a team use Write database migrations? Use it when a schema change and application behavior need to land together. ### What evidence should reviewers check for Write database migrations? A good migration includes explicit indexes, safe defaults, rollback or mitigation notes, and a query that proves the result.
Tutorial Write Database Migrations Create schema changes, seed data, and validation SQL. /docs/tutorials/write-database-migrations.html Guide Database Modernization with Autohand Code Plan safe database changes for legacy and active systems. /docs/guides/database-modernization.html Tutorial Generate a Full CRUD Feature Connect migrations to application behavior and admin workflows. /docs/tutorials/generate-crud-feature.html