Guides
Native database migrations
Apply declared SQL with an explicit environment and inspect the receipt.
For agents: Read the complete native guide and current
context.getcapabilities. Use only implemented operations and preserve exact Account, app and environment authority.
Keep D1 migrations beside the source and declare their directory in wrangler.jsonc. The platform validates names and applies ordered migrations to the owned target database; preview and production have separate migration state.
A failed migration is an operation failure, not permission to expose an unverified candidate. Inspect its bounded diagnostics, preserve the current working deployment, repair the migration and retry with correct intent and revisions. Never claim schema compatibility from compilation alone.
Prefer additive changes when existing app data must survive. Code rollback does not reverse SQL. Restoring data creates isolated resources first; production binding changes require explicit authorized publication. Test the app against the target binding and migration receipt before reporting a recovered production app.