Skip to content

Commit ae4b07a

Browse files
committed
Remove incorrect statement that migrations are not environment specific
1 parent b2a797c commit ae4b07a

File tree

1 file changed

+63
-48
lines changed

1 file changed

+63
-48
lines changed

src/content/docs/durable-objects/reference/durable-objects-migrations.mdx

Lines changed: 63 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ sidebar:
55
order: 2
66
---
77

8-
import { Render, GlossaryTooltip, WranglerConfig, Steps, Details } from "~/components";
8+
import {
9+
Render,
10+
GlossaryTooltip,
11+
WranglerConfig,
12+
Steps,
13+
Details,
14+
} from "~/components";
915

1016
A migration is a mapping process from a class name to a runtime state. This process communicates the changes to the Workers runtime and provides the runtime with instructions on how to deal with those changes.
1117

@@ -36,22 +42,22 @@ To apply a Create migration:
3642
<Steps>
3743
1. Add the following lines to your `wrangler.toml / wrangler.json` file:
3844

39-
<WranglerConfig>
40-
```toml
41-
[[migrations]]
42-
tag = "<v1>" # Migration identifier. This should be unique for each migration entry
43-
new_sqlite_classes = ["<NewDurableObjectClass>"] # Array of new classes
44-
# For SQLite storage backend use new_sqlite_classes=["<NewDurableObjectClass>"] instead
45-
```
46-
</WranglerConfig>
47-
The Create migration contains:
45+
<WranglerConfig>
46+
```toml
47+
[[migrations]]
48+
tag = "<v1>" # Migration identifier. This should be unique for each migration entry
49+
new_sqlite_classes = ["<NewDurableObjectClass>"] # Array of new classes
50+
# For SQLite storage backend use new_sqlite_classes=["<NewDurableObjectClass>"] instead
51+
```
52+
</WranglerConfig>
53+
The Create migration contains:
4854

49-
- A `tag` to identify the migration.
50-
- The array `new_sqlite_classes`, which contains the new Durable Object class.
55+
- A `tag` to identify the migration.
56+
- The array `new_sqlite_classes`, which contains the new Durable Object class.
5157

5258
2. Ensure you reference the correct name of the Durable Object class in your Worker code.
5359
3. Deploy the Worker.
54-
</Steps>
60+
</Steps>
5561

5662
<Details header="Create migration example">
5763

@@ -65,10 +71,12 @@ name = "DURABLE_OBJECT_A"
6571
class_name = "DurableObjectAClass"
6672

6773
# Add the lines below for a Create migration.
74+
6875
[[migrations]]
6976
tag = "v1"
7077
new_sqlite_classes = ["DurableObjectAClass"]
71-
```
78+
79+
````
7280
</WranglerConfig>
7381

7482
</Details>
@@ -89,11 +97,11 @@ Use `new_classes` on the migration in your Worker's Wrangler file to create a Du
8997
[[migrations]]
9098
tag = "v1" # Should be unique for each entry
9199
new_classes = ["MyDurableObject"] # Array of new classes
92-
```
100+
````
93101

94102
</WranglerConfig>
95103

96-
<Render file="do-plans-note"/>
104+
<Render file="do-plans-note" />
97105

98106
## Delete migration
99107

@@ -110,19 +118,20 @@ To apply a Delete migration:
110118
2. Remove references for the class you wish to delete from your Worker code.
111119
3. Add the following lines to your `wrangler.toml / wrangler.json` file.
112120

113-
<WranglerConfig>
114-
```toml
115-
[[migrations]]
116-
tag = "<v2>" # Migration identifier. This should be unique for each migration entry
117-
deleted_classes = ["<ClassToDelete>"] # Array of deleted class names
118-
```
119-
</WranglerConfig>
120-
The Delete migration contains:
121+
<WranglerConfig>
122+
```toml
123+
[[migrations]]
124+
tag = "<v2>" # Migration identifier. This should be unique for each migration entry
125+
deleted_classes = ["<ClassToDelete>"] # Array of deleted class names
126+
```
127+
</WranglerConfig>
128+
The Delete migration contains:
129+
130+
- A `tag` to identify the migration.
131+
- The array `deleted_classes`, which contains the deleted Durable Object classes.
121132

122-
- A `tag` to identify the migration.
123-
- The array `deleted_classes`, which contains the deleted Durable Object classes.
124133
4. Deploy the Worker.
125-
</Steps>
134+
</Steps>
126135

127136
<Details header = "Delete migration example">
128137
To delete a Durable Object binding `DEPRECATED_OBJECT`, your `wrangler.toml / wrangler.json` file should look like the following:
@@ -137,7 +146,8 @@ To delete a Durable Object binding `DEPRECATED_OBJECT`, your `wrangler.toml / wr
137146
[[migrations]]
138147
tag = "v3" # Should be unique for each entry
139148
deleted_classes = ["DeprecatedObjectClass"] # Array of deleted classes
140-
```
149+
150+
````
141151
</WranglerConfig>
142152
</Details>
143153

@@ -187,7 +197,8 @@ class_name = "UpdatedName"
187197
[[migrations]]
188198
tag = "v3"
189199
renamed_classes = [{from = "OldName", to = "UpdatedName" }] # Array of rename directives
190-
```
200+
````
201+
191202
</WranglerConfig>
192203

193204
</Details>
@@ -207,26 +218,27 @@ To apply a Transfer migration:
207218
<Steps>
208219
1. Edit your `wrangler.toml / wrangler.json` file in the following way:
209220

210-
<WranglerConfig>
211-
```toml
212-
[[durable_objects.bindings]]
213-
name = "<MY_DURABLE_OBJECT>"
214-
class_name = "<DestinationDurableObjectClass>"
221+
<WranglerConfig>
222+
```toml
223+
[[durable_objects.bindings]]
224+
name = "<MY_DURABLE_OBJECT>"
225+
class_name = "<DestinationDurableObjectClass>"
226+
227+
[[migrations]]
228+
tag = "<v4>" # Migration identifier. This should be unique for each migration entry
229+
transferred_classes = [{from = "<SourceDurableObjectClass>", from_script = "<SourceWorkerScript>", to = "<DestinationDurableObjectClass>" }]
230+
```
231+
</WranglerConfig>
232+
The Transfer migration contains:
233+
- A `tag` to identify the migration.
234+
- The `transferred_class` array, which contains objects with `from`, `from_script`, and `to` properties.
235+
- `from` property is the name of the source Durable Object class.
236+
- `from_script` property is the name of the source Worker script.
237+
- `to` property is the name of the destination Durable Object class.
215238

216-
[[migrations]]
217-
tag = "<v4>" # Migration identifier. This should be unique for each migration entry
218-
transferred_classes = [{from = "<SourceDurableObjectClass>", from_script = "<SourceWorkerScript>", to = "<DestinationDurableObjectClass>" }]
219-
```
220-
</WranglerConfig>
221-
The Transfer migration contains:
222-
- A `tag` to identify the migration.
223-
- The `transferred_class` array, which contains objects with `from`, `from_script`, and `to` properties.
224-
- `from` property is the name of the source Durable Object class.
225-
- `from_script` property is the name of the source Worker script.
226-
- `to` property is the name of the destination Durable Object class.
227239
2. Ensure you reference the name of the new, destination Durable Object class in your Worker code.
228240
3. Deploy the Worker.
229-
</Steps>
241+
</Steps>
230242

231243
<Details header = "Transfer migration example">
232244

@@ -240,9 +252,11 @@ name = "MY_DURABLE_OBJECT"
240252
class_name = "TransferredClass"
241253

242254
# Transferring class
255+
243256
[[migrations]]
244257
tag = "v4"
245258
transferred_classes = [{from = "DurableObjectExample", from_script = "OldWorkerScript", to = "TransferredClass" }]
259+
246260
```
247261
</WranglerConfig>
248262

@@ -255,7 +269,7 @@ transferred_classes = [{from = "DurableObjectExample", from_script = "OldWorkerS
255269

256270
- Migration tags are treated like unique names and are used to determine which migrations have already been applied. Once a given Worker code has a migration tag set on it, all future Worker code deployments must include a migration tag.
257271

258-
- The migration list is an ordered array of tables, specified as a top-level key in your `wrangler` configuration file. The migration list is inherited by all environments and cannot be overridden by a specific environment.
272+
- The migration list is an ordered array of tables, specified as a top-level key in your `wrangler` configuration file.
259273

260274
- All migrations are applied at deployment. Each migration can only be applied once per [environment](/durable-objects/reference/environments/).
261275

@@ -279,4 +293,5 @@ You cannot enable a SQLite storage backend on an existing, deployed Durable Obje
279293

280294
:::caution[Important]
281295
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. Refer to [Gradual deployments for Durable Objects](/workers/configuration/versions-and-deployments/gradual-deployments/#gradual-deployments-for-durable-objects) for more information.
282-
:::
296+
:::
297+
```

0 commit comments

Comments
 (0)