@proteinjs/db 1.32.3 → 1.33.0
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 +11 -0
- package/dist/src/MigrationRunner.d.ts +14 -3
- package/dist/src/MigrationRunner.d.ts.map +1 -1
- package/dist/src/MigrationRunner.js +56 -28
- package/dist/src/MigrationRunner.js.map +1 -1
- package/dist/src/tables/MigrationTable.d.ts +9 -0
- package/dist/src/tables/MigrationTable.d.ts.map +1 -1
- package/dist/src/tables/MigrationTable.js +1 -0
- package/dist/src/tables/MigrationTable.js.map +1 -1
- package/package.json +2 -2
- package/src/MigrationRunner.ts +29 -4
- package/src/tables/MigrationTable.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.33.0](https://github.com/proteinjs/db/compare/@proteinjs/db@1.32.3...@proteinjs/db@1.33.0) (2026-08-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **db:** retired-migration flag — the deploy series stamps source-less ledger rows and never auto-runs retired rows ([f468125](https://github.com/proteinjs/db/commit/f4681257439e2e7e031f9d7f4d90b7463cc46456))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.32.3](https://github.com/proteinjs/db/compare/@proteinjs/db@1.32.2...@proteinjs/db@1.32.3) (2026-08-15)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -14,8 +14,17 @@ export interface MigrationSeriesSummary {
|
|
|
14
14
|
skippedManual: string[];
|
|
15
15
|
/** Already in 'success' status — skipped (ensureMigrationRun's idempotence). */
|
|
16
16
|
alreadyApplied: string[];
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Ledger rows with no source record (a loader deleted after its run; the table keeps history) —
|
|
19
|
+
* each one is STAMPED `retired: true` by this run, so a source class that ships again later can
|
|
20
|
+
* never silently re-arm it.
|
|
21
|
+
*/
|
|
18
22
|
unresolved: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Rows that arrived already `retired: true` — never auto-run, even when the source class ships
|
|
25
|
+
* again, until someone un-retires them on the Migrations page.
|
|
26
|
+
*/
|
|
27
|
+
retired: string[];
|
|
19
28
|
/** The failure that stopped the series, if any. */
|
|
20
29
|
failed?: {
|
|
21
30
|
id: string;
|
|
@@ -66,8 +75,10 @@ export declare class MigrationRunner implements MigrationRunnerService {
|
|
|
66
75
|
* class keeps the Migrations-page flow ({@link Migration.manual}).
|
|
67
76
|
* - rows already in 'success' are skipped; any other status is pending — including 'running'
|
|
68
77
|
* (a crashed earlier Job): {@link ensureMigrationRun} re-runs it.
|
|
69
|
-
* - rows with no source record are history (a loader deleted after its run) —
|
|
70
|
-
* reported as `unresolved`.
|
|
78
|
+
* - rows with no source record are history (a loader deleted after its run) — STAMPED
|
|
79
|
+
* `retired: true`, skipped, reported as `unresolved`.
|
|
80
|
+
* - rows with `retired: true` are NEVER auto-run — even if the source class returns in a later
|
|
81
|
+
* build — until un-retired on the Migrations page; skipped, reported as `retired`.
|
|
71
82
|
* - the FIRST failure STOPS the series (later migrations may build on earlier ones). The
|
|
72
83
|
* caller exits non-zero, the Job fails, the rollout does not advance.
|
|
73
84
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationRunner.d.ts","sourceRoot":"","sources":["../../src/MigrationRunner.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAA6B,MAAM,mCAAmC,CAAC;AACtG,OAAO,EAAE,SAAS,EAAkB,MAAM,yBAAyB,CAAC;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,eAAO,MAAM,kBAAkB,uBACyE,CAAC;AAEzG;;;;GAIG;AACH,MAAM,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,CAAC,SAAS,CAAC;IAcxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,oBAAoB,IAAI,OAAO,CAAC,sBAAsB,CAAC;YA2E/C,YAAY;IA8B1B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,QAAQ;CA4BjB"}
|
|
@@ -126,8 +126,10 @@ var MigrationRunner = /** @class */ (function () {
|
|
|
126
126
|
* class keeps the Migrations-page flow ({@link Migration.manual}).
|
|
127
127
|
* - rows already in 'success' are skipped; any other status is pending — including 'running'
|
|
128
128
|
* (a crashed earlier Job): {@link ensureMigrationRun} re-runs it.
|
|
129
|
-
* - rows with no source record are history (a loader deleted after its run) —
|
|
130
|
-
* reported as `unresolved`.
|
|
129
|
+
* - rows with no source record are history (a loader deleted after its run) — STAMPED
|
|
130
|
+
* `retired: true`, skipped, reported as `unresolved`.
|
|
131
|
+
* - rows with `retired: true` are NEVER auto-run — even if the source class returns in a later
|
|
132
|
+
* build — until un-retired on the Migrations page; skipped, reported as `retired`.
|
|
131
133
|
* - the FIRST failure STOPS the series (later migrations may build on earlier ones). The
|
|
132
134
|
* caller exits non-zero, the Job fails, the rollout does not advance.
|
|
133
135
|
*
|
|
@@ -159,41 +161,67 @@ var MigrationRunner = /** @class */ (function () {
|
|
|
159
161
|
skippedManual: [],
|
|
160
162
|
alreadyApplied: [],
|
|
161
163
|
unresolved: [],
|
|
164
|
+
retired: [],
|
|
162
165
|
notAttempted: [],
|
|
163
166
|
};
|
|
164
167
|
sourceRecordRepo = new SourceRecordRepo_1.SourceRecordRepo();
|
|
165
168
|
pending = [];
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
169
|
+
_i = 0, ledger_1 = ledger;
|
|
170
|
+
_a.label = 2;
|
|
171
|
+
case 2:
|
|
172
|
+
if (!(_i < ledger_1.length)) return [3 /*break*/, 6];
|
|
173
|
+
row = ledger_1[_i];
|
|
174
|
+
if (row.retired) {
|
|
175
|
+
summary.retired.push(row.id);
|
|
176
|
+
return [3 /*break*/, 5];
|
|
177
|
+
}
|
|
178
|
+
source = sourceRecordRepo.getSourceRecord(migrationTable.name, row.id);
|
|
179
|
+
if (!!source) return [3 /*break*/, 4];
|
|
180
|
+
// Stamp, don't just skip: the ledger must remember the source class was gone. If the
|
|
181
|
+
// class ships again in a later build, the row stays excluded until a human un-retires it
|
|
182
|
+
// on the Migrations page — a returned loader id is not consent to auto-run.
|
|
183
|
+
return [4 /*yield*/, db.update(migrationTable, { id: row.id, retired: true })];
|
|
184
|
+
case 3:
|
|
185
|
+
// Stamp, don't just skip: the ledger must remember the source class was gone. If the
|
|
186
|
+
// class ships again in a later build, the row stays excluded until a human un-retires it
|
|
187
|
+
// on the Migrations page — a returned loader id is not consent to auto-run.
|
|
188
|
+
_a.sent();
|
|
189
|
+
summary.unresolved.push(row.id);
|
|
190
|
+
return [3 /*break*/, 5];
|
|
191
|
+
case 4:
|
|
192
|
+
if (source.manual) {
|
|
193
|
+
summary.skippedManual.push(row.id);
|
|
194
|
+
return [3 /*break*/, 5];
|
|
195
|
+
}
|
|
196
|
+
if (row.status === 'success') {
|
|
197
|
+
summary.alreadyApplied.push(row.id);
|
|
198
|
+
return [3 /*break*/, 5];
|
|
182
199
|
}
|
|
200
|
+
pending.push(row);
|
|
201
|
+
_a.label = 5;
|
|
202
|
+
case 5:
|
|
203
|
+
_i++;
|
|
204
|
+
return [3 /*break*/, 2];
|
|
205
|
+
case 6:
|
|
183
206
|
this.logger.info({
|
|
184
207
|
message: "Running ".concat(pending.length, " pending migration").concat(pending.length === 1 ? '' : 's', " in series, oldest-first"),
|
|
185
|
-
obj: {
|
|
208
|
+
obj: {
|
|
209
|
+
pending: pending.map(function (row) { return row.id; }),
|
|
210
|
+
skippedManual: summary.skippedManual,
|
|
211
|
+
skippedRetired: summary.retired,
|
|
212
|
+
stampedRetired: summary.unresolved,
|
|
213
|
+
},
|
|
186
214
|
});
|
|
187
215
|
i = 0;
|
|
188
|
-
_a.label =
|
|
189
|
-
case
|
|
190
|
-
if (!(i < pending.length)) return [3 /*break*/,
|
|
216
|
+
_a.label = 7;
|
|
217
|
+
case 7:
|
|
218
|
+
if (!(i < pending.length)) return [3 /*break*/, 10];
|
|
191
219
|
return [4 /*yield*/, this.ensureMigrationRun(pending[i].id)];
|
|
192
|
-
case
|
|
220
|
+
case 8:
|
|
193
221
|
outcome = _a.sent();
|
|
194
222
|
if (outcome.status === 'success') {
|
|
195
223
|
summary.applied.push(outcome.id);
|
|
196
|
-
return [3 /*break*/,
|
|
224
|
+
return [3 /*break*/, 9];
|
|
197
225
|
}
|
|
198
226
|
summary.failed = {
|
|
199
227
|
id: outcome.id,
|
|
@@ -201,11 +229,11 @@ var MigrationRunner = /** @class */ (function () {
|
|
|
201
229
|
failureMessage: outcome.failureMessage,
|
|
202
230
|
};
|
|
203
231
|
summary.notAttempted = pending.slice(i + 1).map(function (row) { return row.id; });
|
|
204
|
-
return [3 /*break*/,
|
|
205
|
-
case
|
|
232
|
+
return [3 /*break*/, 10];
|
|
233
|
+
case 9:
|
|
206
234
|
i++;
|
|
207
|
-
return [3 /*break*/,
|
|
208
|
-
case
|
|
235
|
+
return [3 /*break*/, 7];
|
|
236
|
+
case 10:
|
|
209
237
|
this.logger.info({ message: "Migration series finished", obj: summary });
|
|
210
238
|
return [2 /*return*/, summary];
|
|
211
239
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationRunner.js","sourceRoot":"","sources":["../../src/MigrationRunner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA8C;AAC9C,2BAAgD;AAEhD,8DAA6D;AAC7D,4EAAsG;AACtG,0DAAoE;AACpE,6DAA4D;AA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AAI,OAAO,GAAG,CAAC,EAAE;YACf,KAAK,CAAC,IAAI,CAAC,UAAG,OAAO,iBAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAE,CAAC,CAAC;SACvD;QACD,IAAI,OAAO,GAAG,CAAC,EAAE;YACf,KAAK,CAAC,IAAI,CAAC,UAAG,OAAO,iBAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAE,CAAC,CAAC;SACvD;QACD,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,EAAE;YAC3D,KAAK,CAAC,IAAI,CAAC,UAAG,YAAY,QAAK,CAAC,CAAC;SAClC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IACH,sBAAC;AAAD,CAAC,AAjOD,IAiOC;AAjOY,0CAAe"}
|
|
@@ -12,6 +12,14 @@ export interface Migration extends SourceRecord {
|
|
|
12
12
|
* schema, not in deploy-pipeline prose.
|
|
13
13
|
*/
|
|
14
14
|
manual?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Ledger-owned state (like `status` — never declared on a source record): stamped `true` by the
|
|
17
|
+
* deploy-gated series ({@link MigrationRunner.runPendingMigrations}) when the row's source class
|
|
18
|
+
* no longer ships. A retired row is NEVER auto-run — even if its source class returns in a later
|
|
19
|
+
* build — until someone un-retires it on the Migrations page (the record form's Un-retire
|
|
20
|
+
* button). A returned loader id is not consent to auto-run.
|
|
21
|
+
*/
|
|
22
|
+
retired?: boolean;
|
|
15
23
|
status?: 'proposed' | 'running' | 'success' | 'failure';
|
|
16
24
|
failureMessage?: string;
|
|
17
25
|
failureStack?: string;
|
|
@@ -38,6 +46,7 @@ export declare class MigrationTable extends Table<Migration> {
|
|
|
38
46
|
} & {} & {
|
|
39
47
|
description: import("../Table").Column<string, any>;
|
|
40
48
|
manual: import("../Table").Column<boolean | undefined, any>;
|
|
49
|
+
retired: import("../Table").Column<boolean | undefined, any>;
|
|
41
50
|
status: import("../Table").Column<"proposed" | "running" | "success" | "failure" | undefined, any>;
|
|
42
51
|
failureMessage: import("../Table").Column<string | undefined, any>;
|
|
43
52
|
failureStack: import("../Table").Column<string | undefined, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationTable.d.ts","sourceRoot":"","sources":["../../../src/tables/MigrationTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,YAAY,EAA2B,MAAM,wBAAwB,CAAC;AAE/E,MAAM,WAAW,SAAU,SAAQ,YAAY;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,GAAG,EAAE,MAAM,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;CAChC;AAED,qBAAa,cAAe,SAAQ,KAAK,CAAC,SAAS,CAAC;IAC3C,IAAI,SAAe;IAC1B;;;;;OAKG;IACI,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAGnC;IACK,OAAO
|
|
1
|
+
{"version":3,"file":"MigrationTable.d.ts","sourceRoot":"","sources":["../../../src/tables/MigrationTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,YAAY,EAA2B,MAAM,wBAAwB,CAAC;AAE/E,MAAM,WAAW,SAAU,SAAQ,YAAY;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,GAAG,EAAE,MAAM,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;CAChC;AAED,qBAAa,cAAe,SAAQ,KAAK,CAAC,SAAS,CAAC;IAC3C,IAAI,SAAe;IAC1B;;;;;OAKG;IACI,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAGnC;IACK,OAAO;;;;;;;;;;;;;;;;;;MAWX;IACI,mBAAmB;;;;;MAKxB;CACH"}
|
|
@@ -73,6 +73,7 @@ var MigrationTable = /** @class */ (function (_super) {
|
|
|
73
73
|
_this.columns = (0, SourceRecord_1.withSourceRecordColumns)({
|
|
74
74
|
description: new Columns_1.StringColumn('description', {}, 4000),
|
|
75
75
|
manual: new Columns_1.BooleanColumn('manual'),
|
|
76
|
+
retired: new Columns_1.BooleanColumn('retired'),
|
|
76
77
|
status: new Columns_1.StringColumn('status', { defaultValue: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
77
78
|
return [2 /*return*/, 'proposed'];
|
|
78
79
|
}); }); } }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationTable.js","sourceRoot":"","sources":["../../../src/tables/MigrationTable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sCAAuF;AACvF,kCAAiC;AACjC,uDAA+E;
|
|
1
|
+
{"version":3,"file":"MigrationTable.js","sourceRoot":"","sources":["../../../src/tables/MigrationTable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sCAAuF;AACvF,kCAAiC;AACjC,uDAA+E;AA+B/E;IAAoC,kCAAgB;IAApD;QAAA,qEA8BC;QA7BQ,UAAI,GAAG,WAAW,CAAC;QAC1B;;;;;WAKG;QACI,UAAI,GAA6B;YACtC,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE;YAClC,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE;SACxC,CAAC;QACK,aAAO,GAAG,IAAA,sCAAuB,EAAY;YAClD,WAAW,EAAE,IAAI,sBAAY,CAAC,aAAa,EAAE,EAAE,EAAE,IAAI,CAAC;YACtD,MAAM,EAAE,IAAI,uBAAa,CAAC,QAAQ,CAAC;YACnC,OAAO,EAAE,IAAI,uBAAa,CAAC,SAAS,CAAC;YACrC,MAAM,EAAE,IAAI,sBAAY,CAAC,QAAQ,EAAE,EAAE,YAAY,EAAE;oBAAY,sBAAA,UAAU,EAAA;yBAAA,EAAE,CAAC;YAC5E,cAAc,EAAE,IAAI,sBAAY,CAAC,iBAAiB,EAAE,EAAE,EAAE,IAAI,CAAC;YAC7D,YAAY,EAAE,IAAI,sBAAY,CAAC,eAAe,EAAE,EAAE,EAAE,KAAK,CAAC;YAC1D,SAAS,EAAE,IAAI,wBAAc,CAAC,YAAY,CAAC;YAC3C,OAAO,EAAE,IAAI,wBAAc,CAAC,UAAU,CAAC;YACvC,QAAQ,EAAE,IAAI,sBAAY,CAAC,UAAU,CAAC;YACtC,MAAM,EAAE,IAAI,sBAAY,CAAC,QAAQ,CAAC;SACnC,CAAC,CAAC;QACI,yBAAmB,GAAG;YAC3B,8BAA8B,EAAE,IAAI;YACpC,EAAE,EAAE;gBACF,WAAW,EAAE,IAAI;aAClB;SACF,CAAC;;IACJ,CAAC;IAAD,qBAAC;AAAD,CAAC,AA9BD,CAAoC,aAAK,GA8BxC;AA9BY,wCAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proteinjs/db",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.33.0",
|
|
4
4
|
"main": "./dist/generated/index.js",
|
|
5
5
|
"types": "./dist/generated/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"ts-jest": "29.1.1",
|
|
67
67
|
"typescript": "5.2.2"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "23b168ca8f82ba392500b545230adc6e8c761b4e"
|
|
70
70
|
}
|
package/src/MigrationRunner.ts
CHANGED
|
@@ -23,8 +23,17 @@ export interface MigrationSeriesSummary {
|
|
|
23
23
|
skippedManual: string[];
|
|
24
24
|
/** Already in 'success' status — skipped (ensureMigrationRun's idempotence). */
|
|
25
25
|
alreadyApplied: string[];
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Ledger rows with no source record (a loader deleted after its run; the table keeps history) —
|
|
28
|
+
* each one is STAMPED `retired: true` by this run, so a source class that ships again later can
|
|
29
|
+
* never silently re-arm it.
|
|
30
|
+
*/
|
|
27
31
|
unresolved: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Rows that arrived already `retired: true` — never auto-run, even when the source class ships
|
|
34
|
+
* again, until someone un-retires them on the Migrations page.
|
|
35
|
+
*/
|
|
36
|
+
retired: string[];
|
|
28
37
|
/** The failure that stopped the series, if any. */
|
|
29
38
|
failed?: { id: string; description: string; failureMessage?: string };
|
|
30
39
|
/** Ordered after the failure — never started (later migrations may build on earlier ones). */
|
|
@@ -99,8 +108,10 @@ export class MigrationRunner implements MigrationRunnerService {
|
|
|
99
108
|
* class keeps the Migrations-page flow ({@link Migration.manual}).
|
|
100
109
|
* - rows already in 'success' are skipped; any other status is pending — including 'running'
|
|
101
110
|
* (a crashed earlier Job): {@link ensureMigrationRun} re-runs it.
|
|
102
|
-
* - rows with no source record are history (a loader deleted after its run) —
|
|
103
|
-
* reported as `unresolved`.
|
|
111
|
+
* - rows with no source record are history (a loader deleted after its run) — STAMPED
|
|
112
|
+
* `retired: true`, skipped, reported as `unresolved`.
|
|
113
|
+
* - rows with `retired: true` are NEVER auto-run — even if the source class returns in a later
|
|
114
|
+
* build — until un-retired on the Migrations page; skipped, reported as `retired`.
|
|
104
115
|
* - the FIRST failure STOPS the series (later migrations may build on earlier ones). The
|
|
105
116
|
* caller exits non-zero, the Job fails, the rollout does not advance.
|
|
106
117
|
*
|
|
@@ -126,13 +137,22 @@ export class MigrationRunner implements MigrationRunnerService {
|
|
|
126
137
|
skippedManual: [],
|
|
127
138
|
alreadyApplied: [],
|
|
128
139
|
unresolved: [],
|
|
140
|
+
retired: [],
|
|
129
141
|
notAttempted: [],
|
|
130
142
|
};
|
|
131
143
|
const sourceRecordRepo = new SourceRecordRepo();
|
|
132
144
|
const pending: Migration[] = [];
|
|
133
145
|
for (const row of ledger) {
|
|
146
|
+
if (row.retired) {
|
|
147
|
+
summary.retired.push(row.id);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
134
150
|
const source = sourceRecordRepo.getSourceRecord<Migration>(migrationTable.name, row.id);
|
|
135
151
|
if (!source) {
|
|
152
|
+
// Stamp, don't just skip: the ledger must remember the source class was gone. If the
|
|
153
|
+
// class ships again in a later build, the row stays excluded until a human un-retires it
|
|
154
|
+
// on the Migrations page — a returned loader id is not consent to auto-run.
|
|
155
|
+
await db.update(migrationTable, { id: row.id, retired: true } as Partial<Migration>);
|
|
136
156
|
summary.unresolved.push(row.id);
|
|
137
157
|
continue;
|
|
138
158
|
}
|
|
@@ -149,7 +169,12 @@ export class MigrationRunner implements MigrationRunnerService {
|
|
|
149
169
|
|
|
150
170
|
this.logger.info({
|
|
151
171
|
message: `Running ${pending.length} pending migration${pending.length === 1 ? '' : 's'} in series, oldest-first`,
|
|
152
|
-
obj: {
|
|
172
|
+
obj: {
|
|
173
|
+
pending: pending.map((row) => row.id),
|
|
174
|
+
skippedManual: summary.skippedManual,
|
|
175
|
+
skippedRetired: summary.retired,
|
|
176
|
+
stampedRetired: summary.unresolved,
|
|
177
|
+
},
|
|
153
178
|
});
|
|
154
179
|
for (let i = 0; i < pending.length; i++) {
|
|
155
180
|
const outcome = await this.ensureMigrationRun(pending[i].id);
|
|
@@ -14,6 +14,14 @@ export interface Migration extends SourceRecord {
|
|
|
14
14
|
* schema, not in deploy-pipeline prose.
|
|
15
15
|
*/
|
|
16
16
|
manual?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Ledger-owned state (like `status` — never declared on a source record): stamped `true` by the
|
|
19
|
+
* deploy-gated series ({@link MigrationRunner.runPendingMigrations}) when the row's source class
|
|
20
|
+
* no longer ships. A retired row is NEVER auto-run — even if its source class returns in a later
|
|
21
|
+
* build — until someone un-retires it on the Migrations page (the record form's Un-retire
|
|
22
|
+
* button). A returned loader id is not consent to auto-run.
|
|
23
|
+
*/
|
|
24
|
+
retired?: boolean;
|
|
17
25
|
status?: 'proposed' | 'running' | 'success' | 'failure';
|
|
18
26
|
failureMessage?: string;
|
|
19
27
|
failureStack?: string;
|
|
@@ -39,6 +47,7 @@ export class MigrationTable extends Table<Migration> {
|
|
|
39
47
|
public columns = withSourceRecordColumns<Migration>({
|
|
40
48
|
description: new StringColumn('description', {}, 4000),
|
|
41
49
|
manual: new BooleanColumn('manual'),
|
|
50
|
+
retired: new BooleanColumn('retired'),
|
|
42
51
|
status: new StringColumn('status', { defaultValue: async () => 'proposed' }),
|
|
43
52
|
failureMessage: new StringColumn('failure_message', {}, 4000),
|
|
44
53
|
failureStack: new StringColumn('failure_stack', {}, 'MAX'),
|