@balena/pinejs 20.0.0 → 20.0.1-build-rollbackable-migrations-guide-3ca5787deb64488fb03a0a6aa1a22633f4a61bec-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,15 @@
1
+ - commits:
2
+ - subject: "Migrations.md: Update the rollbackable migrations guide"
3
+ hash: 3ca5787deb64488fb03a0a6aa1a22633f4a61bec
4
+ body: ""
5
+ footer:
6
+ Change-type: patch
7
+ change-type: patch
8
+ author: Thodoris Greasidis
9
+ nested: []
10
+ version: 20.0.1
11
+ title: ""
12
+ date: 2025-01-14T08:03:27.861Z
1
13
  - commits:
2
14
  - subject: Update node engines entry to clarify we don't actively support 21.x
3
15
  hash: bb75825da9bf23f38f1c0fe2bae301d171d84de6
@@ -50,7 +62,7 @@
50
62
  nested: []
51
63
  version: 20.0.0
52
64
  title: ""
53
- date: 2025-01-10T11:35:44.131Z
65
+ date: 2025-01-10T18:15:01.199Z
54
66
  - commits:
55
67
  - subject: Use for-of loops in preference of lodash `_.forEach`
56
68
  hash: cef68084a2670d797559c2fd4a36825be67b7729
@@ -2175,6 +2187,7 @@
2175
2187
 
2176
2188
 
2177
2189
 
2190
+
2178
2191
 
2179
2192
 
2180
2193
  As balena-lint
@@ -2221,6 +2234,7 @@
2221
2234
 
2222
2235
 
2223
2236
 
2237
+
2224
2238
 
2225
2239
 
2226
2240
  As engine and npm is
@@ -2282,6 +2296,7 @@
2282
2296
 
2283
2297
 
2284
2298
 
2299
+
2285
2300
 
2286
2301
 
2287
2302
  Ensure that the
@@ -2406,6 +2421,7 @@
2406
2421
 
2407
2422
 
2408
2423
 
2424
+
2409
2425
 
2410
2426
 
2411
2427
  This also deprecates
@@ -2458,6 +2474,7 @@
2458
2474
 
2459
2475
 
2460
2476
 
2477
+
2461
2478
 
2462
2479
 
2463
2480
  It can in fact be a
@@ -2511,6 +2528,7 @@
2511
2528
 
2512
2529
 
2513
2530
 
2531
+
2514
2532
 
2515
2533
 
2516
2534
  We know what type
@@ -2569,6 +2587,7 @@
2569
2587
 
2570
2588
 
2571
2589
 
2590
+
2572
2591
 
2573
2592
 
2574
2593
  Update
@@ -2738,6 +2757,7 @@
2738
2757
 
2739
2758
 
2740
2759
 
2760
+
2741
2761
 
2742
2762
 
2743
2763
  This also deprecates
package/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file
4
4
  automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
5
5
  This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ # v20.0.1
8
+ ## (2025-01-14)
9
+
10
+ * Migrations.md: Update the rollbackable migrations guide [Thodoris Greasidis]
11
+
7
12
  # v20.0.0
8
13
  ## (2025-01-10)
9
14
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 20.0.0
1
+ 20.0.1
@@ -65,23 +65,6 @@ Async migrations are stored in the migrations folder, alongside synchronous migr
65
65
  The async migration query must have a `LIMIT` statement to limit the maximum number of affected rows per batch.
66
66
 
67
67
 
68
- ### Async migration procedure
69
- * Deployment 1
70
- - Add new column (with independent sync migration) to contain new data and add code accessing the new column.
71
- - Update the service's implementation to set both the old & new column on each write.
72
- - The service's implementation should only read the old column since the async migration still migrates data from old column to new column.
73
- - Async migrator runs forever.
74
- * Deployment 2
75
- - Finalize async migration => only sync migration part gets executed.
76
- - Sync migration migrates all left over data from old column to new column.
77
- - Update the service's implementation to only read the new column, but still write the old one as well.
78
- - Mark the old field as optional in the sbvr if it isn't, or set a default value for it.
79
- * Deployment 3
80
- - Update the service's implementation to stop settings the old column and remove it from the sbvr.
81
- - Make the old field NULLable if it isn't.
82
- * Deployment 4
83
- - Delete the old column with a sync migration.
84
-
85
68
  ### TS migration file format with SQL query string
86
69
 
87
70
  The placeholder `%%ASYNC_BATCH_SIZE%%` will be replaced with the value specified by asyncBatchSize parameter
@@ -147,4 +130,34 @@ export = {
147
130
 
148
131
  ```
149
132
  ### SQL query file (plain text)
150
- Plain SQL files are not supported as they cannot bundle async and sync migration statements in one file. Moreover they cannot carry migration metadata.
133
+ Plain SQL files are not supported as they cannot bundle async and sync migration statements in one file. Moreover they cannot carry migration metadata.
134
+
135
+ ## Rollbackable no-down-time suggested migration procedure
136
+
137
+ * Deployment 1
138
+ - Add the new column with an independent sync migration.
139
+ - Add an Async migrator that starts migrating data from the old column to new column (optional optimization for big tables).
140
+ - Update the service's implementation to set both the old & new column on each write.
141
+ The service's implementation should only read the old column, since not all data has been migrated to the new column yet.
142
+ * Deployment 2
143
+ - Complete the data migration from the old to the new column:
144
+ - Either finalize the async migration from deployment 1 if you are using one.
145
+ This causes the sync part of the migration to execute.
146
+ - Or write a sync migration otherwise.
147
+ - Mark the new column as non-NULL if applicable as part of the above migration.
148
+ - Update the service's implementation to only read the new column, but still write to the old one as well.
149
+ - Test that the implementation works even if we keep the old column as NOT NULLable.
150
+ This makes sure that older service instances can still work during the deployment.
151
+ - Mark the old field as NULLable if it isn't.
152
+ * Deployment 3
153
+ - Update the service's implementation to stop writing to the old column
154
+ - Remove the old column from the SBVR, leaving a TODO to also DROP if from the DB in a follow-up.
155
+ The old column needs to stay in the DB so that older service instances can still work during the deployment.
156
+ * Deployment 4
157
+ - DROP the old column with a sync migration.
158
+
159
+ ### Testing rollbacks
160
+ For each step, be sure and utilize testing to ensure you can safely rollback to previous versions of your service even with the updated database schemas (with data) deployed.
161
+ Before merging each step, try rolling back your development environment to the previous deployment and make sure that everything still works without issues.
162
+ The old deployment should be able to operate with DB records created by the new deployment and leave the DB in a valid state.
163
+ Eg: While testing the PR for deployment 2 on your development environment, make sure that if you push deplpoyment 1 everything still works without issues.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@balena/pinejs",
3
- "version": "20.0.0",
3
+ "version": "20.0.1-build-rollbackable-migrations-guide-3ca5787deb64488fb03a0a6aa1a22633f4a61bec-2",
4
4
  "main": "out/server-glue/module.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:balena-io/pinejs.git",
@@ -148,6 +148,6 @@
148
148
  "recursive": true
149
149
  },
150
150
  "versionist": {
151
- "publishedAt": "2025-01-10T11:35:45.108Z"
151
+ "publishedAt": "2025-01-14T08:03:28.831Z"
152
152
  }
153
153
  }