Skip to content
Esc
↑↓navigate↵open⌘Jpreview
Start
On this page

Write database migrations

Ask Autohand Code to inspect current migrations, add a safe schema change, and update API code that depends on it.

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 Code CLI Playbook, CLI reference, and configuration reference 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.

Last updated on

Was this helpful?

Send Feedback

Help us improve this documentation page. Your feedback is valuable.

We'll only contact you if we need clarification