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
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.
11
17
@@ -36,22 +42,22 @@ To apply a Create migration:
36
42
<Steps>
37
43
1. Add the following lines to your `wrangler.toml / wrangler.json` file:
38
44
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:
48
54
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.
51
57
52
58
2. Ensure you reference the correct name of the Durable Object class in your Worker code.
53
59
3. Deploy the Worker.
54
-
</Steps>
60
+
</Steps>
55
61
56
62
<Detailsheader="Create migration example">
57
63
@@ -65,10 +71,12 @@ name = "DURABLE_OBJECT_A"
65
71
class_name = "DurableObjectAClass"
66
72
67
73
# Add the lines below for a Create migration.
74
+
68
75
[[migrations]]
69
76
tag = "v1"
70
77
new_sqlite_classes = ["DurableObjectAClass"]
71
-
```
78
+
79
+
````
72
80
</WranglerConfig>
73
81
74
82
</Details>
@@ -89,11 +97,11 @@ Use `new_classes` on the migration in your Worker's Wrangler file to create a Du
89
97
[[migrations]]
90
98
tag = "v1"# Should be unique for each entry
91
99
new_classes = ["MyDurableObject"] # Array of new classes
92
-
```
100
+
````
93
101
94
102
</WranglerConfig>
95
103
96
-
<Renderfile="do-plans-note"/>
104
+
<Render file="do-plans-note"/>
97
105
98
106
## Delete migration
99
107
@@ -110,19 +118,20 @@ To apply a Delete migration:
110
118
2. Remove references for the class you wish to delete from your Worker code.
111
119
3. Add the following lines to your `wrangler.toml / wrangler.json` file.
112
120
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.
121
132
122
-
- A `tag` to identify the migration.
123
-
- The array `deleted_classes`, which contains the deleted Durable Object classes.
124
133
4. Deploy the Worker.
125
-
</Steps>
134
+
</Steps>
126
135
127
136
<Detailsheader="Delete migration example">
128
137
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
137
146
[[migrations]]
138
147
tag = "v3"# Should be unique for each entry
139
148
deleted_classes = ["DeprecatedObjectClass"] # Array of deleted classes
140
-
```
149
+
150
+
````
141
151
</WranglerConfig>
142
152
</Details>
143
153
@@ -187,7 +197,8 @@ class_name = "UpdatedName"
187
197
[[migrations]]
188
198
tag = "v3"
189
199
renamed_classes = [{from = "OldName", to = "UpdatedName" }] # Array of rename directives
190
-
```
200
+
````
201
+
191
202
</WranglerConfig>
192
203
193
204
</Details>
@@ -207,26 +218,27 @@ To apply a Transfer migration:
207
218
<Steps>
208
219
1. Edit your `wrangler.toml / wrangler.json` file in the following way:
209
220
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
- 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.
257
271
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.
259
273
260
274
- All migrations are applied at deployment. Each migration can only be applied once per [environment](/durable-objects/reference/environments/).
261
275
@@ -279,4 +293,5 @@ You cannot enable a SQLite storage backend on an existing, deployed Durable Obje
279
293
280
294
:::caution[Important]
281
295
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.
0 commit comments