@nauth-toolkit/database-typeorm-mysql 0.3.2 → 0.4.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/dist/entities/api-key.entity.d.ts.map +1 -1
- package/dist/entities/api-key.entity.js +6 -1
- package/dist/entities/api-key.entity.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/migration-lock.d.ts +54 -0
- package/dist/utils/migration-lock.d.ts.map +1 -0
- package/dist/utils/migration-lock.js +125 -0
- package/dist/utils/migration-lock.js.map +1 -0
- package/dist/utils/run-migrations.d.ts +6 -0
- package/dist/utils/run-migrations.d.ts.map +1 -1
- package/dist/utils/run-migrations.js +64 -12
- package/dist/utils/run-migrations.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-key.entity.d.ts","sourceRoot":"","sources":["../../src/entities/api-key.entity.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC;;;;;;;;;;;;GAYG;AACH,qBAMa,MAAO,SAAQ,UAAU;IAE5B,EAAE,EAAE,MAAM,CAAC;IAGX,KAAK,EAAE,MAAM,CAAC;IAGd,MAAM,EAAE,MAAM,CAAC;IAIvB,IAAI,EAAG,IAAI,CAAC;IAGJ,OAAO,EAAE,MAAM,CAAC;IAGhB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAGrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAGzB,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAG7B,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAGxB,QAAQ,EAAE,OAAO,CAAC;IAGlB,SAAS,CAAC,EAAE,I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AM,CAAC;IAGnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAG1C,SAAS,EAAE,IAAI,CAAC;IAQhB,SAAS,EAAE,IAAI,CAAC;CACzB"}
|
|
@@ -104,7 +104,12 @@ __decorate([
|
|
|
104
104
|
__metadata("design:type", Date)
|
|
105
105
|
], ApiKey.prototype, "createdAt", void 0);
|
|
106
106
|
__decorate([
|
|
107
|
-
(0, typeorm_1.UpdateDateColumn)({
|
|
107
|
+
(0, typeorm_1.UpdateDateColumn)({
|
|
108
|
+
type: 'timestamp',
|
|
109
|
+
precision: 6,
|
|
110
|
+
default: () => 'CURRENT_TIMESTAMP(6)',
|
|
111
|
+
onUpdate: 'CURRENT_TIMESTAMP(6)',
|
|
112
|
+
}),
|
|
108
113
|
__metadata("design:type", Date)
|
|
109
114
|
], ApiKey.prototype, "updatedAt", void 0);
|
|
110
115
|
exports.ApiKey = ApiKey = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-key.entity.js","sourceRoot":"","sources":["../../src/entities/api-key.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCASiB;AACjB,8CAAiD;AACjD,+CAAqC;AAErC;;;;;;;;;;;;GAYG;AAOI,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,iBAAU;IAYpC,IAAI,CAAQ;
|
|
1
|
+
{"version":3,"file":"api-key.entity.js","sourceRoot":"","sources":["../../src/entities/api-key.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCASiB;AACjB,8CAAiD;AACjD,+CAAqC;AAErC;;;;;;;;;;;;GAYG;AAOI,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,iBAAU;IAYpC,IAAI,CAAQ;CAmDb,CAAA;AA/DY,wBAAM;AAET;IADP,IAAA,gCAAsB,GAAE;;kCACN;AAGX;IADP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE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C,CAAC,UAAU,CAAC,CAAC;IACnB,IAAA,eAAK,EAAC,CAAC,WAAW,CAAC,CAAC;GACR,MAAM,CA+DlB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,4 +14,16 @@ export * from './entities';
|
|
|
14
14
|
* Consumers should not need to call this directly.
|
|
15
15
|
*/
|
|
16
16
|
export { runNAuthMigrations } from './utils/run-migrations';
|
|
17
|
+
/**
|
|
18
|
+
* Migration lock helpers (MySQL).
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Exported so consumers applying migrations out-of-band (an ECS one-off task, a
|
|
22
|
+
* Kubernetes Job) can take the same lock nauth-toolkit uses and stay mutually
|
|
23
|
+
* exclusive with any instance that still boots with `migrations.autoRun` enabled.
|
|
24
|
+
* The lock is a session-scoped named lock (`GET_LOCK`) derived from the migrations
|
|
25
|
+
* table name.
|
|
26
|
+
*/
|
|
27
|
+
export { acquireMigrationLock, computeNamedLockKey, MIGRATION_LOCK_TIMEOUT_MS } from './utils/migration-lock';
|
|
28
|
+
export type { MigrationLockHandle } from './utils/migration-lock';
|
|
17
29
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,gBAAgB,EAAE,gCAAgC,EAAE,MAAM,YAAY,CAAC;AAGhF,cAAc,YAAY,CAAC;AAM3B;;;;;;GAMG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,gBAAgB,EAAE,gCAAgC,EAAE,MAAM,YAAY,CAAC;AAGhF,cAAc,YAAY,CAAC;AAM3B;;;;;;GAMG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D;;;;;;;;;GASG;AACH,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAC9G,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
20
20
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.runNAuthMigrations = exports.getNAuthTransientStorageEntities = exports.getNAuthEntities = void 0;
|
|
23
|
+
exports.MIGRATION_LOCK_TIMEOUT_MS = exports.computeNamedLockKey = exports.acquireMigrationLock = exports.runNAuthMigrations = exports.getNAuthTransientStorageEntities = exports.getNAuthEntities = void 0;
|
|
24
24
|
// Export helper function for getting entities (preferred)
|
|
25
25
|
var entities_1 = require("./entities");
|
|
26
26
|
Object.defineProperty(exports, "getNAuthEntities", { enumerable: true, get: function () { return entities_1.getNAuthEntities; } });
|
|
@@ -39,4 +39,18 @@ __exportStar(require("./entities"), exports);
|
|
|
39
39
|
*/
|
|
40
40
|
var run_migrations_1 = require("./utils/run-migrations");
|
|
41
41
|
Object.defineProperty(exports, "runNAuthMigrations", { enumerable: true, get: function () { return run_migrations_1.runNAuthMigrations; } });
|
|
42
|
+
/**
|
|
43
|
+
* Migration lock helpers (MySQL).
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* Exported so consumers applying migrations out-of-band (an ECS one-off task, a
|
|
47
|
+
* Kubernetes Job) can take the same lock nauth-toolkit uses and stay mutually
|
|
48
|
+
* exclusive with any instance that still boots with `migrations.autoRun` enabled.
|
|
49
|
+
* The lock is a session-scoped named lock (`GET_LOCK`) derived from the migrations
|
|
50
|
+
* table name.
|
|
51
|
+
*/
|
|
52
|
+
var migration_lock_1 = require("./utils/migration-lock");
|
|
53
|
+
Object.defineProperty(exports, "acquireMigrationLock", { enumerable: true, get: function () { return migration_lock_1.acquireMigrationLock; } });
|
|
54
|
+
Object.defineProperty(exports, "computeNamedLockKey", { enumerable: true, get: function () { return migration_lock_1.computeNamedLockKey; } });
|
|
55
|
+
Object.defineProperty(exports, "MIGRATION_LOCK_TIMEOUT_MS", { enumerable: true, get: function () { return migration_lock_1.MIGRATION_LOCK_TIMEOUT_MS; } });
|
|
42
56
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;AAEH,0DAA0D;AAC1D,uCAAgF;AAAvE,4GAAA,gBAAgB,OAAA;AAAE,4HAAA,gCAAgC,OAAA;AAE3D,4EAA4E;AAC5E,6CAA2B;AAE3B,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E;;;;;;GAMG;AACH,yDAA4D;AAAnD,oHAAA,kBAAkB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;AAEH,0DAA0D;AAC1D,uCAAgF;AAAvE,4GAAA,gBAAgB,OAAA;AAAE,4HAAA,gCAAgC,OAAA;AAE3D,4EAA4E;AAC5E,6CAA2B;AAE3B,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E;;;;;;GAMG;AACH,yDAA4D;AAAnD,oHAAA,kBAAkB,OAAA;AAE3B;;;;;;;;;GASG;AACH,yDAA8G;AAArG,sHAAA,oBAAoB,OAAA;AAAE,qHAAA,mBAAmB,OAAA;AAAE,2HAAA,yBAAyB,OAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { DataSource } from 'typeorm';
|
|
2
|
+
import type { NAuthLogger } from '@nauth-toolkit/core';
|
|
3
|
+
/**
|
|
4
|
+
* How long to wait for another instance to finish migrating before giving up.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Deliberately not configurable. Long enough to cover a realistic migration on a large
|
|
8
|
+
* table, short enough that a genuinely stuck deploy fails with a clear error instead of
|
|
9
|
+
* hanging forever.
|
|
10
|
+
*/
|
|
11
|
+
export declare const MIGRATION_LOCK_TIMEOUT_MS = 300000;
|
|
12
|
+
/**
|
|
13
|
+
* A held MySQL named lock.
|
|
14
|
+
*/
|
|
15
|
+
export interface MigrationLockHandle {
|
|
16
|
+
/**
|
|
17
|
+
* Release the named lock and return its connection to the pool.
|
|
18
|
+
*
|
|
19
|
+
* Safe to call more than once.
|
|
20
|
+
*/
|
|
21
|
+
release(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Derive a stable MySQL named lock string from the migrations table name.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* MySQL caps lock names at 64 characters, so the table name is hashed rather than
|
|
28
|
+
* embedded. Deriving from the table name means two applications sharing one database
|
|
29
|
+
* but using different `tablePrefix` values migrate independently.
|
|
30
|
+
*
|
|
31
|
+
* @param migrationsTableName - Name of the nauth migrations table
|
|
32
|
+
* @returns Lock name (49 characters)
|
|
33
|
+
*/
|
|
34
|
+
export declare function computeNamedLockKey(migrationsTableName: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Acquire a MySQL/MariaDB session-level named lock for the migration run.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* The lock is held on a dedicated `QueryRunner` connection for the entire migration run.
|
|
40
|
+
* MySQL releases named locks automatically when the connection ends, so a crashed or
|
|
41
|
+
* killed instance can never leave a permanent lock behind — this is why a named lock is
|
|
42
|
+
* used rather than a lock row in a table.
|
|
43
|
+
*
|
|
44
|
+
* Locking matters more on MySQL than on PostgreSQL: MySQL commits implicitly on DDL, so
|
|
45
|
+
* two instances running the same migration concurrently can leave the schema half
|
|
46
|
+
* applied with no rollback.
|
|
47
|
+
*
|
|
48
|
+
* @param dataSource - Initialized DataSource used for the migration run
|
|
49
|
+
* @param migrationsTableName - Name of the nauth migrations table (scopes the lock)
|
|
50
|
+
* @param logger - NAuth logger instance
|
|
51
|
+
* @returns A handle to release the lock, or `null` if it could not be acquired in time
|
|
52
|
+
*/
|
|
53
|
+
export declare function acquireMigrationLock(dataSource: DataSource, migrationsTableName: string, logger: NAuthLogger): Promise<MigrationLockHandle | null>;
|
|
54
|
+
//# sourceMappingURL=migration-lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-lock.d.ts","sourceRoot":"","sources":["../../src/utils/migration-lock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAejD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAOD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAMvE;AAWD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,UAAU,EACtB,mBAAmB,EAAE,MAAM,EAC3B,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAyDrC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MIGRATION_LOCK_TIMEOUT_MS = void 0;
|
|
4
|
+
exports.computeNamedLockKey = computeNamedLockKey;
|
|
5
|
+
exports.acquireMigrationLock = acquireMigrationLock;
|
|
6
|
+
const crypto_1 = require("crypto");
|
|
7
|
+
/**
|
|
8
|
+
* How long to wait for another instance to finish migrating before giving up.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Deliberately not configurable. Long enough to cover a realistic migration on a large
|
|
12
|
+
* table, short enough that a genuinely stuck deploy fails with a clear error instead of
|
|
13
|
+
* hanging forever.
|
|
14
|
+
*/
|
|
15
|
+
exports.MIGRATION_LOCK_TIMEOUT_MS = 300_000;
|
|
16
|
+
/**
|
|
17
|
+
* Delay between named lock acquisition attempts while waiting.
|
|
18
|
+
*/
|
|
19
|
+
const LOCK_RETRY_DELAY_MS = 1_000;
|
|
20
|
+
/**
|
|
21
|
+
* Longest single `GET_LOCK` wait, in seconds.
|
|
22
|
+
*
|
|
23
|
+
* `GET_LOCK` blocks the connection for its timeout, so it is called in short slices to
|
|
24
|
+
* keep the overall wait bounded and loggable.
|
|
25
|
+
*/
|
|
26
|
+
const GET_LOCK_SLICE_SECONDS = 5;
|
|
27
|
+
/**
|
|
28
|
+
* Derive a stable MySQL named lock string from the migrations table name.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* MySQL caps lock names at 64 characters, so the table name is hashed rather than
|
|
32
|
+
* embedded. Deriving from the table name means two applications sharing one database
|
|
33
|
+
* but using different `tablePrefix` values migrate independently.
|
|
34
|
+
*
|
|
35
|
+
* @param migrationsTableName - Name of the nauth migrations table
|
|
36
|
+
* @returns Lock name (49 characters)
|
|
37
|
+
*/
|
|
38
|
+
function computeNamedLockKey(migrationsTableName) {
|
|
39
|
+
const digest = (0, crypto_1.createHash)('sha256')
|
|
40
|
+
.update(`nauth-toolkit:migrations:${migrationsTableName}`)
|
|
41
|
+
.digest('hex')
|
|
42
|
+
.slice(0, 32);
|
|
43
|
+
return `nauth_migrations_${digest}`;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Pause for the given number of milliseconds.
|
|
47
|
+
*
|
|
48
|
+
* @param ms - Delay in milliseconds
|
|
49
|
+
*/
|
|
50
|
+
function delay(ms) {
|
|
51
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Acquire a MySQL/MariaDB session-level named lock for the migration run.
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* The lock is held on a dedicated `QueryRunner` connection for the entire migration run.
|
|
58
|
+
* MySQL releases named locks automatically when the connection ends, so a crashed or
|
|
59
|
+
* killed instance can never leave a permanent lock behind — this is why a named lock is
|
|
60
|
+
* used rather than a lock row in a table.
|
|
61
|
+
*
|
|
62
|
+
* Locking matters more on MySQL than on PostgreSQL: MySQL commits implicitly on DDL, so
|
|
63
|
+
* two instances running the same migration concurrently can leave the schema half
|
|
64
|
+
* applied with no rollback.
|
|
65
|
+
*
|
|
66
|
+
* @param dataSource - Initialized DataSource used for the migration run
|
|
67
|
+
* @param migrationsTableName - Name of the nauth migrations table (scopes the lock)
|
|
68
|
+
* @param logger - NAuth logger instance
|
|
69
|
+
* @returns A handle to release the lock, or `null` if it could not be acquired in time
|
|
70
|
+
*/
|
|
71
|
+
async function acquireMigrationLock(dataSource, migrationsTableName, logger) {
|
|
72
|
+
const lockName = computeNamedLockKey(migrationsTableName);
|
|
73
|
+
const queryRunner = dataSource.createQueryRunner();
|
|
74
|
+
await queryRunner.connect();
|
|
75
|
+
let released = false;
|
|
76
|
+
const handle = {
|
|
77
|
+
async release() {
|
|
78
|
+
if (released)
|
|
79
|
+
return;
|
|
80
|
+
released = true;
|
|
81
|
+
try {
|
|
82
|
+
await queryRunner.query('SELECT RELEASE_LOCK(?) AS acquired', [lockName]);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
// Non-fatal: MySQL drops the lock when the session ends.
|
|
86
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
87
|
+
logger.warn(`[nauth-toolkit] Failed to release migration named lock: ${message}`);
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
await queryRunner.release();
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
const deadline = Date.now() + exports.MIGRATION_LOCK_TIMEOUT_MS;
|
|
95
|
+
let waitLogged = false;
|
|
96
|
+
try {
|
|
97
|
+
for (;;) {
|
|
98
|
+
const remainingMs = deadline - Date.now();
|
|
99
|
+
const sliceSeconds = Math.max(0, Math.min(GET_LOCK_SLICE_SECONDS, Math.ceil(remainingMs / 1000)));
|
|
100
|
+
const rows = (await queryRunner.query('SELECT GET_LOCK(?, ?) AS acquired', [
|
|
101
|
+
lockName,
|
|
102
|
+
sliceSeconds,
|
|
103
|
+
]));
|
|
104
|
+
// GET_LOCK returns 1 on success, 0 on timeout, NULL on error.
|
|
105
|
+
if (Number(rows[0]?.acquired) === 1) {
|
|
106
|
+
logger.debug(`[nauth-toolkit] Acquired migration named lock (${lockName})`);
|
|
107
|
+
return handle;
|
|
108
|
+
}
|
|
109
|
+
if (Date.now() >= deadline) {
|
|
110
|
+
await queryRunner.release();
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
if (!waitLogged) {
|
|
114
|
+
waitLogged = true;
|
|
115
|
+
logger.log('[nauth-toolkit] Another instance is applying migrations; waiting for it to finish...');
|
|
116
|
+
}
|
|
117
|
+
await delay(LOCK_RETRY_DELAY_MS);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
await queryRunner.release();
|
|
122
|
+
throw err;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=migration-lock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-lock.js","sourceRoot":"","sources":["../../src/utils/migration-lock.ts"],"names":[],"mappings":";;;AAuDA,kDAMC;AA6BD,oDA6DC;AAvJD,mCAAoC;AAIpC;;;;;;;GAOG;AACU,QAAA,yBAAyB,GAAG,OAAO,C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AAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;QAC5B,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -8,6 +8,12 @@ import type { NAuthConfig, NAuthLogger } from '@nauth-toolkit/core';
|
|
|
8
8
|
* ensuring zero interference with consumer migrations. The consumer's DataSource
|
|
9
9
|
* is never modified or accessed for migration purposes.
|
|
10
10
|
*
|
|
11
|
+
* The run is serialized across instances by a MySQL session-level named lock, so
|
|
12
|
+
* containers that boot in parallel (ECS tasks, Kubernetes pods) cannot race to create the
|
|
13
|
+
* same tables on a first deployment or apply the same migration twice on a later one.
|
|
14
|
+
* Instances that lose the race wait for the winner and then find nothing left to do. The
|
|
15
|
+
* lock is released by the database if an instance dies, so it can never wedge a deploy.
|
|
16
|
+
*
|
|
11
17
|
* @param dataSource - Consumer's DataSource (only used to extract connection config)
|
|
12
18
|
* @param logger - NAuth logger instance
|
|
13
19
|
* @param config - NAuth configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-migrations.d.ts","sourceRoot":"","sources":["../../src/utils/run-migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"run-migrations.d.ts","sourceRoot":"","sources":["../../src/utils/run-migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAsFpE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CA2Ef"}
|
|
@@ -4,6 +4,29 @@ exports.runNAuthMigrations = runNAuthMigrations;
|
|
|
4
4
|
const typeorm_1 = require("typeorm");
|
|
5
5
|
const migrations_1 = require("../migrations");
|
|
6
6
|
const entities_1 = require("../entities");
|
|
7
|
+
const migration_lock_1 = require("./migration-lock");
|
|
8
|
+
/**
|
|
9
|
+
* Check whether any nauth migrations are still pending.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* Used only on the lock-timeout path, to distinguish "another instance already did the
|
|
13
|
+
* work" from "the schema is genuinely out of date". Treats a failed check as pending so
|
|
14
|
+
* an unclear state fails loudly instead of starting on an unmigrated schema.
|
|
15
|
+
*
|
|
16
|
+
* @param dataSource - Initialized nauth DataSource
|
|
17
|
+
* @param logger - NAuth logger instance
|
|
18
|
+
* @returns True if migrations remain unapplied (or the check could not be performed)
|
|
19
|
+
*/
|
|
20
|
+
async function hasPendingMigrations(dataSource, logger) {
|
|
21
|
+
try {
|
|
22
|
+
return await dataSource.showMigrations();
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
26
|
+
logger.warn(`[nauth-toolkit] Could not determine pending migrations: ${message}`);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
7
30
|
function getMigrationsTableName(config) {
|
|
8
31
|
const tablePrefix = config.tablePrefix ?? 'nauth_';
|
|
9
32
|
return `${tablePrefix}migrations`;
|
|
@@ -48,6 +71,12 @@ function extractConnectionConfig(dataSource) {
|
|
|
48
71
|
* ensuring zero interference with consumer migrations. The consumer's DataSource
|
|
49
72
|
* is never modified or accessed for migration purposes.
|
|
50
73
|
*
|
|
74
|
+
* The run is serialized across instances by a MySQL session-level named lock, so
|
|
75
|
+
* containers that boot in parallel (ECS tasks, Kubernetes pods) cannot race to create the
|
|
76
|
+
* same tables on a first deployment or apply the same migration twice on a later one.
|
|
77
|
+
* Instances that lose the race wait for the winner and then find nothing left to do. The
|
|
78
|
+
* lock is released by the database if an instance dies, so it can never wedge a deploy.
|
|
79
|
+
*
|
|
51
80
|
* @param dataSource - Consumer's DataSource (only used to extract connection config)
|
|
52
81
|
* @param logger - NAuth logger instance
|
|
53
82
|
* @param config - NAuth configuration
|
|
@@ -70,19 +99,42 @@ async function runNAuthMigrations(dataSource, logger, config) {
|
|
|
70
99
|
try {
|
|
71
100
|
// Initialize the isolated nauth DataSource
|
|
72
101
|
await nauthDataSource.initialize();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (!
|
|
80
|
-
|
|
81
|
-
|
|
102
|
+
// ============================================================================
|
|
103
|
+
// Acquire the cross-instance migration lock
|
|
104
|
+
// ============================================================================
|
|
105
|
+
// Without this, instances starting in parallel each see an empty migrations table
|
|
106
|
+
// and race to apply the same DDL.
|
|
107
|
+
const lock = await (0, migration_lock_1.acquireMigrationLock)(nauthDataSource, migrationsTableName, logger);
|
|
108
|
+
if (!lock) {
|
|
109
|
+
// Timed out waiting for the instance that holds the lock. Continue only if it
|
|
110
|
+
// already applied everything; never migrate concurrently.
|
|
111
|
+
if (!(await hasPendingMigrations(nauthDataSource, logger))) {
|
|
112
|
+
logger.warn(`[nauth-toolkit] Timed out after ${migration_lock_1.MIGRATION_LOCK_TIMEOUT_MS}ms waiting for the migration lock, but no migrations are pending; continuing startup.`);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
throw new Error(`[nauth-toolkit] Timed out after ${migration_lock_1.MIGRATION_LOCK_TIMEOUT_MS}ms waiting for another instance to finish migrations, and migrations are still pending. ` +
|
|
116
|
+
`Apply migrations before rolling out and set migrations.autoRun to false, or investigate the instance holding the lock.`);
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
logger.log(`[nauth-toolkit] Running ${migrations_1.migrations.length} NAuth migration(s) using isolated DataSource (table: ${migrationsTableName})`);
|
|
120
|
+
logger.log('[nauth-toolkit] Checking for pending migrations...');
|
|
121
|
+
// Run migrations on the isolated DataSource
|
|
122
|
+
const executed = (await nauthDataSource.runMigrations({
|
|
123
|
+
transaction: 'all',
|
|
124
|
+
}));
|
|
125
|
+
if (!executed.length) {
|
|
126
|
+
logger.log('[nauth-toolkit] No pending migrations.');
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
logger.log(`[nauth-toolkit] Executed ${executed.length} migration(s):`);
|
|
130
|
+
for (const m of executed)
|
|
131
|
+
logger.log(` ${m.name}`);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
// Release before destroying the DataSource so the lock is dropped explicitly
|
|
135
|
+
// rather than relying on connection teardown.
|
|
136
|
+
await lock.release();
|
|
82
137
|
}
|
|
83
|
-
logger.log(`[nauth-toolkit] Executed ${executed.length} migration(s):`);
|
|
84
|
-
for (const m of executed)
|
|
85
|
-
logger.log(` ${m.name}`);
|
|
86
138
|
}
|
|
87
139
|
finally {
|
|
88
140
|
// Always destroy the isolated DataSource to clean up connections
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-migrations.js","sourceRoot":"","sources":["../../src/utils/run-migrations.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"run-migrations.js","sourceRoot":"","sources":["../../src/utils/run-migrations.ts"],"names":[],"mappings":";;AAyGA,gDA+EC;AAxLD,qCAAqC;AAErC,8CAA2C;AAC3C,0CAAiF;AACjF,qDAAmF;AAInF;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,oBAAoB,CAAC,UAAsB,EAAE,MAAmB;IAC7E,IAAI,CAAC;QACH,OAAO,MAAM,UAAU,CAAC,cAAc,EAAE,CAAC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,MAAM,C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AAQ,CAAC,MAAM,gBAAgB,CAAC,CAAC;YACxE,KAAK,MAAM,CAAC,IAAI,QAAQ;gBAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACtD,CAAC;gBAAS,CAAC;YACT,6EAA6E;YAC7E,8CAA8C;YAC9C,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;YAAS,CAAC;QACT,iEAAiE;QACjE,IAAI,eAAe,CAAC,aAAa,EAAE,CAAC;YAClC,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nauth-toolkit/database-typeorm-mysql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "MySQL storage adapter for nauth-toolkit via TypeORM",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"format:check": "prettier --check \"src/**/*.ts\""
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@nauth-toolkit/core": "^0.
|
|
17
|
+
"@nauth-toolkit/core": "^0.4.0",
|
|
18
18
|
"typeorm": "^0.3.20",
|
|
19
19
|
"mysql2": "^2.3.0 || ^3.0.0"
|
|
20
20
|
},
|