You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/durable-objects/reference/durable-objects-migrations.mdx
+14-17Lines changed: 14 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -139,19 +139,16 @@ To apply a Rename migration:
139
139
renamed_classes = [{from = "<OldDurableObject>", to = "<UpdatedDurableObject>" }] # Array of rename directives
140
140
```
141
141
</WranglerConfig>
142
+
142
143
The Rename migration contains:
143
144
- A `tag` to identify the migration.
144
145
- The `renamed_classes` array, which contains objects with `from` and `to` properties.
145
-
- `from` property is the name of the old Durable Object class.
146
-
- `to` property is the name of the renamed Durable Object class.
146
+
- `from` property is the old Durable Object class name.
147
+
- `to` property is the renamed Durable Object class name.
147
148
2. Reference the new Durable Object class name in your Worker code.
148
149
3. Deploy the Worker.
149
150
</Steps>
150
151
151
-
:::note
152
-
To apply both migrations in the same deploy, add the migrations configuration and deploy the Worker.
153
-
:::
154
-
155
152
<Detailsheader="Rename migration example">
156
153
157
154
To rename a Durable Object class, from `OldName` to `UpdatedName`, your `wrangler.toml / wrangler.json` file should look like the following:
@@ -209,16 +206,6 @@ To apply a Transfer migration:
209
206
3. Deploy the Worker.
210
207
</Steps>
211
208
212
-
:::caution[Important]
213
-
- The destination class (the class that stored Durable Objects are being transferred to) for a Rename or Transfer migration must be exported by the deployed Worker.
214
-
215
-
- You should not create the destination Durable Object class before running a Rename or Transfer migration. The migration will create the destination class for you.
216
-
217
-
- After a Rename or Transfer migration, requests to the destination Durable Object class will have access to the source Durable Object's stored data.
218
-
219
-
- After a migration, any existing bindings to the original Durable Object class (for example, from other Workers) will automatically forward to the updated destination class. However, any Workers bound to the updated Durable Object class must update their Durable Object binding configuration in the `wrangler` configuration file for their next deployment.
220
-
:::
221
-
222
209
<Detailsheader="Transfer migration example">
223
210
224
211
You can transfer stored Durable Objects from `DurableObjectExample` to `TransferredClass` from a Worker script named `OldWorkerScript`. The configuration of the `wrangler.toml / wrangler.json` file for your new Worker code (destination Worker code) would look like this:
## Durable Object migrations configuration in the Wrangler configuration file
228
+
## Migration Wrangler configuration
242
229
243
230
- Migrations are performed through the `[[migrations]]` configurations key in your `wrangler.toml` file or `migration` key in your `wrangler.json` file.
- Each migration in the list can have multiple directives, and multiple migrations can be specified as your project grows in complexity.
254
241
242
+
:::caution[Important]
243
+
- The destination class (the class that stored Durable Objects are being transferred to) for a Rename or Transfer migration must be exported by the deployed Worker.
244
+
245
+
- You should not create the destination Durable Object class before running a Rename or Transfer migration. The migration will create the destination class for you.
246
+
247
+
- After a Rename or Transfer migration, requests to the destination Durable Object class will have access to the source Durable Object's stored data.
248
+
249
+
- After a migration, any existing bindings to the original Durable Object class (for example, from other Workers) will automatically forward to the updated destination class. However, any Workers bound to the updated Durable Object class must update their Durable Object binding configuration in the `wrangler` configuration file for their next deployment.
250
+
:::
251
+
255
252
:::note
256
253
Note that `.toml` files do not allow line breaks in inline tables (the `{key = "value"}` syntax), but line breaks in the surrounding inline array are acceptable.
0 commit comments