@proteinjs/db 1.34.3 → 1.35.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 +22 -0
- package/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/generated/test/index.d.ts.map +1 -1
- package/dist/generated/test/index.js +3 -1
- package/dist/generated/test/index.js.map +1 -1
- package/dist/src/Db.d.ts +10 -0
- package/dist/src/Db.d.ts.map +1 -1
- package/dist/src/Db.js +42 -2
- package/dist/src/Db.js.map +1 -1
- package/dist/src/MigrationRunner.d.ts +26 -0
- package/dist/src/MigrationRunner.d.ts.map +1 -1
- package/dist/src/MigrationRunner.js +82 -0
- package/dist/src/MigrationRunner.js.map +1 -1
- package/dist/src/source/SourceRecord.d.ts +35 -2
- package/dist/src/source/SourceRecord.d.ts.map +1 -1
- package/dist/src/source/SourceRecord.js +8 -1
- package/dist/src/source/SourceRecord.js.map +1 -1
- package/dist/src/source/SourceRecordLoader.d.ts +105 -7
- package/dist/src/source/SourceRecordLoader.d.ts.map +1 -1
- package/dist/src/source/SourceRecordLoader.js +358 -94
- package/dist/src/source/SourceRecordLoader.js.map +1 -1
- package/dist/src/tables/MigrationTable.d.ts +26 -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/dist/test/reusable/SourceRecordSyncTests.d.ts.map +1 -1
- package/dist/test/reusable/SourceRecordSyncTests.js +803 -27
- package/dist/test/reusable/SourceRecordSyncTests.js.map +1 -1
- package/dist/test/util/tables/sourceRecordSyncTestTables.d.ts +16 -0
- package/dist/test/util/tables/sourceRecordSyncTestTables.d.ts.map +1 -1
- package/dist/test/util/tables/sourceRecordSyncTestTables.js +23 -1
- package/dist/test/util/tables/sourceRecordSyncTestTables.js.map +1 -1
- package/generated/index.ts +1 -1
- package/generated/test/index.ts +3 -1
- package/package.json +4 -4
- package/src/Db.ts +19 -0
- package/src/MigrationRunner.ts +62 -0
- package/src/source/SourceRecord.ts +42 -4
- package/src/source/SourceRecordLoader.ts +342 -48
- package/src/tables/MigrationTable.ts +24 -0
- package/test/reusable/SourceRecordSyncTests.ts +462 -11
- package/test/util/tables/sourceRecordSyncTestTables.ts +20 -0
|
@@ -12,6 +12,29 @@ export interface Migration extends SourceRecord {
|
|
|
12
12
|
* schema, not in deploy-pipeline prose.
|
|
13
13
|
*/
|
|
14
14
|
manual?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Runs during `Db.init()` BEFORE schema sync (the pre-schema-sync phase —
|
|
17
|
+
* {@link MigrationRunner.runPreSchemaSyncMigrations}), instead of after init like the
|
|
18
|
+
* deploy-gated series. This is the class for data repairs a NEW SCHEMA INVARIANT depends on —
|
|
19
|
+
* e.g. deduplicating rows before a unique index lands: schema sync's unique-index preflight
|
|
20
|
+
* fails loudly over violating data ({@link DuplicateValuesForUniqueIndexError}), and the
|
|
21
|
+
* ordinary series (deploy Job, after init) is too late by construction.
|
|
22
|
+
*
|
|
23
|
+
* Contract for this class (stricter than the ordinary automated class):
|
|
24
|
+
* - IDEMPOTENT and tolerant of CONCURRENT duplicate runs: every booting replica and the deploy
|
|
25
|
+
* Job each run init — two actors can observe the row un-applied and both run the body.
|
|
26
|
+
* - TABLE-EXISTENCE tolerant: on a fresh database the body runs before ANY schema sync, so its
|
|
27
|
+
* target tables may not exist yet (check and no-op — a fresh database has nothing to repair).
|
|
28
|
+
* - Never `manual` (a contradiction — the phase exists to run unattended before DDL; declaring
|
|
29
|
+
* both fails init loudly).
|
|
30
|
+
* A failure fails `Db.init()` loudly (recorded on the ledger row, retried next boot) — exactly
|
|
31
|
+
* the failure the schema sync would otherwise hit, but named and retryable.
|
|
32
|
+
*
|
|
33
|
+
* The phase reads the SOURCE declaration (like {@link runPendingMigrations} reads
|
|
34
|
+
* `source.manual`); the column mirrors it into the ledger so the Migrations page shows why a
|
|
35
|
+
* row ran at boot.
|
|
36
|
+
*/
|
|
37
|
+
preSchemaSync?: boolean;
|
|
15
38
|
/**
|
|
16
39
|
* Ledger-owned state (like `status` — never declared on a source record): stamped `true` by the
|
|
17
40
|
* deploy-gated series ({@link MigrationRunner.runPendingMigrations}) when the row's source class
|
|
@@ -43,9 +66,12 @@ export declare class MigrationTable extends Table<Migration> {
|
|
|
43
66
|
created: import("../Table").Column<Moment, any>;
|
|
44
67
|
updated: import("../Table").Column<Moment, any>;
|
|
45
68
|
isLoadedFromSource: import("../Table").Column<boolean | undefined, any>;
|
|
69
|
+
sourcePackage: import("../Table").Column<string | undefined, any>;
|
|
70
|
+
sourcePackageVersion: import("../Table").Column<string | undefined, any>;
|
|
46
71
|
} & {} & {
|
|
47
72
|
description: import("../Table").Column<string, any>;
|
|
48
73
|
manual: import("../Table").Column<boolean | undefined, any>;
|
|
74
|
+
preSchemaSync: import("../Table").Column<boolean | undefined, any>;
|
|
49
75
|
retired: import("../Table").Column<boolean | undefined, any>;
|
|
50
76
|
status: import("../Table").Column<"proposed" | "running" | "success" | "failure" | undefined, any>;
|
|
51
77
|
failureMessage: 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;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IACxD,c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G,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;;;;;;;;;;;;;;;;;;;;;MAYX;IACI,mBAAmB,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC,CAMjE;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
|
+
preSchemaSync: new Columns_1.BooleanColumn('pre_schema_sync'),
|
|
76
77
|
retired: new Columns_1.BooleanColumn('retired'),
|
|
77
78
|
status: new Columns_1.StringColumn('status', { defaultValue: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
78
79
|
return [2 /*return*/, 'proposed'];
|
|
@@ -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;AAsD/E;IAAoC,kCAAgB;IAApD;QAAA,qEAgCC;QA/BQ,UAAI,GAAG,WAAW,CAAC;QAC1B;;;;;WAK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ests.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,QAAQ,EAKR,KAAK,
|
|
1
|
+
{"version":3,"file":"SourceRecordSyncTests.d.ts","sourceRoot":"","sources":["../../../test/reusable/SourceRecordSyncTests.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,QAAQ,EAKR,KAAK,EAKN,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AAsCtE;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,WACxB,QAAQ,6BACW,gCAAgC,qBACxC,MAAM,GAAG,CAAC,KAAK,QAAQ,IAAI,CAAC,eAoqBhD,CAAC"}
|