Back up the deployment
Use a protected backup directory outside the source checkout. Do not place API keys, resource IDs, or customer data in the repository or a support request.Export D1
Fromapps/rooms, export data without the schema:
Clone every workspace’s Git history
Read the workspace IDs from the D1 export. Clone each one through the public API origin:Copy both R2 buckets
The usercontent bucket stores text objects attext/<workspace-id>/<blob-sha>. The asset bucket stores objects at
<workspace-id>/<content-hash>. Read those values from D1, then fetch each
object:
wrangler has no r2 object list command. For many objects, use the
Cloudflare dashboard or an S3-compatible client instead of one command per
key.
Restore D1 metadata
Do not replay a rawwrangler d1 export file. The table order can break
foreign-key checks. Current wrangler also has no d1 import command.
1
Create a fresh D1 database
database_name and database_id values equal.2
Apply the source migrations
From
apps/rooms, run:3
Prepare the data-only import
Keep only Save the result as
INSERT statements from the backup. Remove every
d1_migrations row. Order the inserts by table:data-only-parent-first.sql outside the repository.4
Import the rows
5
Check row counts
d1 execute --file can cancel
at a confirmation prompt while exiting with status 0, so do not skip this
check.Update both Workers
Back up the deployment before any update that adds a D1 migration.- Check out the new named source tag and read its migration notes.
- Install the locked dependencies and build the browser app.
- Copy your resource values into the new app and usercontent config templates.
- Apply pending D1 migrations.
- Deploy the app Worker and the usercontent Worker from the same source tag.
/healthz on every origin, sign in through Access, open and edit a known
document, check living and exact-version raw links, and test one API-key request
and Git fetch.
