Data and migrations
Migrations only add
Numbered .sql files in migrations/, applied to DB in order. New tables, new columns (nullable or with a
default), new indexes. Never DROP, RENAME or change a column's meaning: the release script refuses it unless
given --allow-destructive "<reason>".
Migrations run before new code is deployed, and code can be rolled back for 7 days while the schema stays. So new code must work on the previous release's data, and the previous release must keep working with the new schema. Read new columns defensively.
All data stays in the instance's own D1, R2 and KV, and counts toward the product's storage allowance. Near it,
owners are warned; over it, your app's init answers "storage": "over".
Cloning
With clone in the manifest, owners can clone an instance: a new one on the original's release, with its data
copied in.
- Database: exported and imported whole; tables in
skip_tablesare then emptied. - Files: the buckets
r2names are copied; others start empty. KV starts empty. Durable Object storage can't be copied: don't addcloneif you keep lasting data there. - Secrets:
randomandvapidare new unless listed incopy_secrets(list the ones that encrypt stored data). - Knowing it's a copy: the copy's init returns its own new id. Store your app id; when init returns a different one, your data came from another app, so clean up what belonged to the original.
- Not copied: address, custom domains, owners and analytics.