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
- Each migration in the list can have multiple directives, and multiple migrations can be specified as your project grows in complexity.
241
248
242
249
:::caution[Important]
250
+
243
251
- 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
252
245
253
- 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
254
247
255
- 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
256
249
257
- 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
-
:::
258
+
:::
251
259
252
260
:::note
253
261
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.
254
262
:::
255
263
256
-
{/* ## Examples of Durable Object migration
264
+
{/\* ## Examples of Durable Object migration
257
265
258
266
To illustrate an example migrations workflow, the `DurableObjectExample` class can be initially defined with:
259
267
@@ -268,7 +276,7 @@ new_classes = ["DurableObjectExample"] # Array of new classes
268
276
269
277
</WranglerConfig>
270
278
271
-
You can rename the `DurableObjectExample` class to `UpdatedName` and delete an outdated `DeprecatedClass` entirely. You can create separate migrations for each operation, or combine them into a single migration as shown below. */}
279
+
You can rename the `DurableObjectExample` class to `UpdatedName` and delete an outdated `DeprecatedClass` entirely. You can create separate migrations for each operation, or combine them into a single migration as shown below. \*/}
272
280
273
281
## Enable SQLite storage backend on new Durable Object class migration
274
282
@@ -293,3 +301,7 @@ new_sqlite_classes = ["MyDurableObject"] # Array of new classes
293
301
For an example of a new class migration, refer to [Get started: Configure Durable Object class with SQLite storage backend](/durable-objects/get-started/tutorial-with-sql-api/#6-configure-durable-object-class-with-sqlite-storage-backend).
294
302
295
303
You cannot enable a SQLite storage backend on an existing, deployed Durable Object class, so setting `new_sqlite_classes` on later migrations will fail with an error. Automatic migration of deployed classes from their key-value storage backend to SQLite storage backend will be available in the future.
304
+
305
+
:::caution[Important]
306
+
Durable Object migrations are atomic operations and cannot be gradually deployed. To provide early feedback to developers, new Worker versions with new migrations cannot be uploaded. Read through [Gradual deployments for Durable Objects](/workers/configuration/versions-and-deployments/gradual-deployments/#gradual-deployments-for-durable-objects) for more information.
Due to[global uniqueness](/durable-objects/platform/known-issues/#global-uniqueness), only one version of each [Durable Object](/durable-objects/) can run at a time. This means that gradual deployments work slightly differently for Durable Objects.
200
+
To provide[global uniqueness](/durable-objects/platform/known-issues/#global-uniqueness), only one version of each [Durable Object](/durable-objects/) can run at a time. This means that gradual deployments work slightly differently for Durable Objects.
201
201
202
-
When you create a new gradual deployment for a Durable Object Worker, each Durable Object is assigned a Worker version based on the percentages you configured in your [deployment](/workers/configuration/versions-and-deployments/#deployments). This version will not change until you create a new deployment.
202
+
When you create a new gradual deployment for a Worker with Durable Objects, each Durable Object is assigned a Worker version based on the percentages you configured in your [deployment](/workers/configuration/versions-and-deployments/#deployments). This version will not change until you create a new deployment.
@@ -226,12 +226,24 @@ This is only an example, so the versions assigned to your Durable Objects may be
226
226
227
227
:::note
228
228
229
-
Typically, your Durable Object Worker will define both your Durable Object class and the Worker that interacts with it. In this case, you cannot deploy changes to your Durable Object and its Worker independently.
229
+
Typically, a Worker bundle will define both the Durable Object class and a Worker that interacts with it. In this case, you cannot deploy changes to your Durable Object and its Worker independently.
230
230
231
231
You should ensure that API changes between your Durable Object and its Worker are [forwards and backwards compatible](/durable-objects/platform/known-issues/#code-updates) whether you are using gradual deployments or not. However, using gradual deployments will make it even more likely that different versions of your Durable Objects and its Worker will interact with each other.
232
232
233
233
:::
234
234
235
+
### Migrations
236
+
237
+
Versions of Worker bundles containing new Durable Object migrations cannot be uploaded. This is because Durable Object migrations are atomic operations. Durable Object migrations can be deployed with the following command:
238
+
239
+
```sh
240
+
npx wrangler versions deploy
241
+
```
242
+
243
+
In order to limit the blast radius of Durable Object migration deployments, migrations should be deployed independently of other code changes.
244
+
245
+
To understand why Durable Object migrations are atomic operations, consider the hypothetical example of gradually deploying a delete migration. If a delete migration were applied to 50% of Durable Object instances, then Workers requesting those Durable Object instances would fail because they would have been deleted. To do this without producing errors, a version of the Worker which does not depend on any Durable Object instances would have to have already been rolled out. At which point you can deploy a delete migration without affecting any traffic and there is no reason to do so gradually.
246
+
235
247
## Observability
236
248
237
249
When using gradual deployments, you may want to attribute Workers invocations to a specific version in order to get visibility into the impact of deploying new versions.
0 commit comments