@prairielearn/migrations 3.0.24 → 3.0.25
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.
- package/CHANGELOG.md +8 -0
- package/README.md +9 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -60,19 +60,24 @@ A `makeBatchedMigration()` function is available to help ensure you're writing a
|
|
|
60
60
|
```ts
|
|
61
61
|
// batched-migrations/20230411002409_example_migration.ts
|
|
62
62
|
import { makeBatchedMigration } from '@prairielearn/migrations';
|
|
63
|
-
import {
|
|
63
|
+
import { queryRow, execute } from '@prairielearn/postgres';
|
|
64
64
|
|
|
65
65
|
export default makeBatchedMigration({
|
|
66
66
|
async getParameters() {
|
|
67
|
-
const
|
|
67
|
+
const max = await queryRow(
|
|
68
|
+
'SELECT MAX(id) as max from examples;',
|
|
69
|
+
z.bigint({ coerce: true }).nullable(),
|
|
70
|
+
);
|
|
71
|
+
|
|
68
72
|
return {
|
|
69
|
-
|
|
73
|
+
min: 1n,
|
|
74
|
+
max,
|
|
70
75
|
batchSize: 1000,
|
|
71
76
|
};
|
|
72
77
|
},
|
|
73
78
|
|
|
74
79
|
async execute(min: bigint, max: bigint) {
|
|
75
|
-
await
|
|
80
|
+
await execute('UPDATE examples SET text = TRIM(text) WHERE id >= $min AND id <= $max', {
|
|
76
81
|
min,
|
|
77
82
|
max,
|
|
78
83
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prairielearn/migrations",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@prairielearn/error": "^2.0.19",
|
|
18
18
|
"@prairielearn/logger": "^2.0.20",
|
|
19
19
|
"@prairielearn/named-locks": "^3.0.23",
|
|
20
|
-
"@prairielearn/postgres": "^4.
|
|
20
|
+
"@prairielearn/postgres": "^4.2.0",
|
|
21
21
|
"fs-extra": "^11.3.1",
|
|
22
22
|
"serialize-error": "^12.0.0",
|
|
23
23
|
"zod": "^3.25.76"
|