@webiny/data-migration 0.0.0-unstable.de38392959 → 0.0.0-unstable.df7a8bb475
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/MigrationRunner.d.ts +6 -4
- package/MigrationRunner.js +71 -25
- package/MigrationRunner.js.map +1 -1
- package/README.md +9 -4
- package/cli/CliMigrationRunReporter.d.ts +8 -5
- package/cli/CliMigrationRunReporter.js +15 -20
- package/cli/CliMigrationRunReporter.js.map +1 -1
- package/cli/InteractiveCliStatusReporter.d.ts +3 -3
- package/cli/InteractiveCliStatusReporter.js +4 -12
- package/cli/InteractiveCliStatusReporter.js.map +1 -1
- package/cli/LogReporter.d.ts +1 -1
- package/cli/LogReporter.js +3 -10
- package/cli/LogReporter.js.map +1 -1
- package/cli/LogStream.js +3 -10
- package/cli/LogStream.js.map +1 -1
- package/cli/MigrationRunReporter.d.ts +1 -1
- package/cli/MigrationRunReporter.js +1 -5
- package/cli/MigrationRunReporter.js.map +1 -1
- package/cli/MigrationRunner.d.ts +4 -3
- package/cli/MigrationRunner.js +9 -17
- package/cli/MigrationRunner.js.map +1 -1
- package/cli/MigrationStatusReporter.d.ts +1 -1
- package/cli/MigrationStatusReporter.js +1 -5
- package/cli/MigrationStatusReporter.js.map +1 -1
- package/cli/NonInteractiveCliStatusReporter.d.ts +3 -3
- package/cli/NonInteractiveCliStatusReporter.js +1 -8
- package/cli/NonInteractiveCliStatusReporter.js.map +1 -1
- package/cli/VoidStatusReporter.d.ts +1 -1
- package/cli/VoidStatusReporter.js +1 -8
- package/cli/VoidStatusReporter.js.map +1 -1
- package/cli/getDuration.js +1 -8
- package/cli/getDuration.js.map +1 -1
- package/cli/index.d.ts +10 -9
- package/cli/index.js +10 -104
- package/cli/index.js.map +1 -1
- package/createPinoLogger.d.ts +4 -60
- package/createPinoLogger.js +9 -18
- package/createPinoLogger.js.map +1 -1
- package/createTable.d.ts +3 -3
- package/createTable.js +3 -11
- package/createTable.js.map +1 -1
- package/handlers/createDdbEsProjectMigration.d.ts +5 -5
- package/handlers/createDdbEsProjectMigration.js +24 -30
- package/handlers/createDdbEsProjectMigration.js.map +1 -1
- package/handlers/createDdbProjectMigration.d.ts +4 -4
- package/handlers/createDdbProjectMigration.js +22 -28
- package/handlers/createDdbProjectMigration.js.map +1 -1
- package/handlers/createPatternMatcher.d.ts +1 -1
- package/handlers/createPatternMatcher.js +3 -11
- package/handlers/createPatternMatcher.js.map +1 -1
- package/handlers/devVersionErrorResponse.js +1 -8
- package/handlers/devVersionErrorResponse.js.map +1 -1
- package/index.d.ts +6 -7
- package/index.js +6 -71
- package/index.js.map +1 -1
- package/package.json +19 -35
- package/repository/migrations.repository.d.ts +2 -2
- package/repository/migrations.repository.js +38 -64
- package/repository/migrations.repository.js.map +1 -1
- package/symbols.js +7 -20
- package/symbols.js.map +1 -1
- package/types.d.ts +4 -3
- package/types.js +1 -5
- package/types.js.map +1 -1
- package/repository/createStandardEntity.d.ts +0 -51
- package/repository/createStandardEntity.js +0 -39
- package/repository/createStandardEntity.js.map +0 -1
package/MigrationRunner.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Logger } from "@webiny/logger";
|
|
2
|
-
import { MigrationRepository, DataMigration, ExecutionTimeLimiter, MigrationStatus } from "./types";
|
|
3
|
-
export
|
|
1
|
+
import type { Logger } from "@webiny/logger";
|
|
2
|
+
import type { MigrationRepository, DataMigration, ExecutionTimeLimiter, MigrationStatus } from "./types.js";
|
|
3
|
+
export type IsMigrationApplicable = (migration: DataMigration) => boolean;
|
|
4
4
|
export declare class MigrationRunner {
|
|
5
5
|
private readonly logger;
|
|
6
6
|
private readonly migrations;
|
|
@@ -9,7 +9,7 @@ export declare class MigrationRunner {
|
|
|
9
9
|
private context;
|
|
10
10
|
constructor(repository: MigrationRepository, timeLimiter: ExecutionTimeLimiter, migrations: DataMigration[], logger: Logger | undefined);
|
|
11
11
|
setContext(context: Record<string, any>): void;
|
|
12
|
-
execute(projectVersion: string, isApplicable?: IsMigrationApplicable): Promise<void>;
|
|
12
|
+
execute(projectVersion: string, isApplicable?: IsMigrationApplicable, forceExecute?: boolean): Promise<void>;
|
|
13
13
|
getStatus(): Promise<MigrationStatus>;
|
|
14
14
|
private validateIds;
|
|
15
15
|
private createCheckpoint;
|
|
@@ -17,4 +17,6 @@ export declare class MigrationRunner {
|
|
|
17
17
|
private getOrCreateRunItem;
|
|
18
18
|
private setRunItem;
|
|
19
19
|
private setRunItemAndSave;
|
|
20
|
+
private printForceExecuteEnvVars;
|
|
21
|
+
private printSkipExecuteEnvVars;
|
|
20
22
|
}
|
package/MigrationRunner.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
exports.MigrationRunner = void 0;
|
|
7
|
-
var _semver = require("semver");
|
|
8
|
-
var _ioc = require("@webiny/ioc");
|
|
9
|
-
var _utils = require("@webiny/utils");
|
|
10
|
-
var _symbols = require("./symbols");
|
|
11
|
-
var _createPinoLogger = require("./createPinoLogger");
|
|
1
|
+
import { coerce } from "semver";
|
|
2
|
+
import { inject, makeInjectable } from "@webiny/ioc";
|
|
3
|
+
import { executeWithRetry, mdbid } from "@webiny/utils";
|
|
4
|
+
import { MigrationRepositorySymbol, LoggerSymbol, MigrationSymbol, ExecutionTimeLimiterSymbol } from "./symbols.js";
|
|
5
|
+
import { createPinoLogger, getChildLogger } from "./createPinoLogger.js";
|
|
12
6
|
const getCurrentISOTime = () => {
|
|
13
7
|
return new Date().toISOString();
|
|
14
8
|
};
|
|
@@ -18,27 +12,43 @@ const getRunItemDuration = runItem => {
|
|
|
18
12
|
}
|
|
19
13
|
return new Date(runItem.finishedOn).getTime() - new Date(runItem.startedOn).getTime();
|
|
20
14
|
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This allows us to force-execute a migration, even if it's not in the list of the applicable migrations.
|
|
18
|
+
* Example: WEBINY_MIGRATION_FORCE_EXECUTE_5_35_0_006=true
|
|
19
|
+
*/
|
|
21
20
|
const shouldForceExecute = mig => {
|
|
22
21
|
const key = `WEBINY_MIGRATION_FORCE_EXECUTE_${mig.getId().replace(/[\.\-]/g, "_")}`;
|
|
23
22
|
return process.env[key] === "true";
|
|
24
23
|
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* This allows us to always skip a migration.
|
|
27
|
+
* Example: WEBINY_MIGRATION_SKIP_5_35_0_006=true
|
|
28
|
+
*/
|
|
29
|
+
const shouldSkip = mig => {
|
|
30
|
+
const key = `WEBINY_MIGRATION_SKIP_${mig.getId().replace(/[\.\-]/g, "_")}`;
|
|
31
|
+
return process.env[key] === "true";
|
|
32
|
+
};
|
|
25
33
|
class MigrationNotFinished extends Error {}
|
|
26
34
|
class MigrationInProgress extends Error {}
|
|
27
|
-
class MigrationRunner {
|
|
35
|
+
export class MigrationRunner {
|
|
28
36
|
context = {};
|
|
29
37
|
constructor(repository, timeLimiter, migrations, logger) {
|
|
30
38
|
this.repository = repository;
|
|
31
39
|
this.timeLimiter = timeLimiter;
|
|
32
40
|
this.migrations = migrations || [];
|
|
33
41
|
if (!logger) {
|
|
34
|
-
logger =
|
|
42
|
+
logger = createPinoLogger();
|
|
35
43
|
}
|
|
36
44
|
this.logger = logger;
|
|
37
45
|
}
|
|
38
46
|
setContext(context) {
|
|
39
47
|
this.context = context;
|
|
40
48
|
}
|
|
41
|
-
async execute(projectVersion, isApplicable
|
|
49
|
+
async execute(projectVersion, isApplicable,
|
|
50
|
+
// Force execute applicable migrations.
|
|
51
|
+
forceExecute = false) {
|
|
42
52
|
const lastRun = await this.getOrCreateRun();
|
|
43
53
|
try {
|
|
44
54
|
this.validateIds(this.migrations);
|
|
@@ -57,7 +67,7 @@ class MigrationRunner {
|
|
|
57
67
|
|
|
58
68
|
// Get current version, and coerce it to a valid SemVer.
|
|
59
69
|
// With this, we can run migrations targeted for stable versions, released under a preid tag (e.g., `beta`).
|
|
60
|
-
const currentVersion =
|
|
70
|
+
const currentVersion = coerce(projectVersion) + "";
|
|
61
71
|
const startingId = latestMigration ? latestMigration.id : `${currentVersion}-000`;
|
|
62
72
|
const lastId = `${currentVersion}-999`;
|
|
63
73
|
|
|
@@ -83,7 +93,19 @@ class MigrationRunner {
|
|
|
83
93
|
return mig.getId() > startingId && mig.getId() <= lastId;
|
|
84
94
|
};
|
|
85
95
|
const isMigrationApplicable = isApplicable || defaultIsApplicable;
|
|
96
|
+
this.printForceExecuteEnvVars();
|
|
97
|
+
this.printSkipExecuteEnvVars();
|
|
98
|
+
if (forceExecute) {
|
|
99
|
+
this.logger.info(`ALL APPLICABLE MIGRATIONS WILL BE FORCE-EXECUTED! (via --force flag)`);
|
|
100
|
+
}
|
|
86
101
|
const executableMigrations = this.migrations.filter(mig => {
|
|
102
|
+
if (shouldSkip(mig)) {
|
|
103
|
+
this.setRunItem(lastRun, {
|
|
104
|
+
id: mig.getId(),
|
|
105
|
+
status: "skipped"
|
|
106
|
+
});
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
87
109
|
if (shouldForceExecute(mig)) {
|
|
88
110
|
return true;
|
|
89
111
|
}
|
|
@@ -107,7 +129,7 @@ class MigrationRunner {
|
|
|
107
129
|
for (const migration of executableMigrations) {
|
|
108
130
|
const runItem = this.getOrCreateRunItem(lastRun, migration);
|
|
109
131
|
const checkpoint = await this.repository.getCheckpoint(migration.getId());
|
|
110
|
-
const logger =
|
|
132
|
+
const logger = getChildLogger(this.logger, migration);
|
|
111
133
|
if (checkpoint) {
|
|
112
134
|
this.logger.info(checkpoint, `Found checkpoint ${migration.getId()}.`);
|
|
113
135
|
}
|
|
@@ -115,7 +137,7 @@ class MigrationRunner {
|
|
|
115
137
|
projectVersion,
|
|
116
138
|
logger,
|
|
117
139
|
checkpoint,
|
|
118
|
-
forceExecute: shouldForceExecute(migration),
|
|
140
|
+
forceExecute: forceExecute || shouldForceExecute(migration),
|
|
119
141
|
runningOutOfTime: shouldCreateCheckpoint,
|
|
120
142
|
createCheckpoint: async data => {
|
|
121
143
|
await this.createCheckpoint(migration, data);
|
|
@@ -127,7 +149,7 @@ class MigrationRunner {
|
|
|
127
149
|
}
|
|
128
150
|
};
|
|
129
151
|
try {
|
|
130
|
-
const shouldExecute = checkpoint ||
|
|
152
|
+
const shouldExecute = checkpoint || context.forceExecute ? true : await migration.shouldExecute(context);
|
|
131
153
|
if (!shouldExecute) {
|
|
132
154
|
this.logger.info(`Skipping migration %s.`, migration.getId());
|
|
133
155
|
runItem.status = "skipped";
|
|
@@ -167,12 +189,15 @@ class MigrationRunner {
|
|
|
167
189
|
this.logger.error(err, err.message);
|
|
168
190
|
return;
|
|
169
191
|
} finally {
|
|
170
|
-
// We sum duration from the previous run with the current run.
|
|
171
192
|
runItem.finishedOn = getCurrentISOTime();
|
|
172
193
|
|
|
173
194
|
// Update run stats.
|
|
174
195
|
await this.setRunItemAndSave(lastRun, runItem);
|
|
175
|
-
|
|
196
|
+
if (runItem.status === "pending") {
|
|
197
|
+
this.logger.info(`Pausing migration %s, awaiting continuation.`, migration.getId());
|
|
198
|
+
} else {
|
|
199
|
+
this.logger.info(`Finished executing migration %s in %sms.`, migration.getId(), getRunItemDuration(runItem));
|
|
200
|
+
}
|
|
176
201
|
}
|
|
177
202
|
await this.repository.logMigration({
|
|
178
203
|
id: migration.getId(),
|
|
@@ -228,7 +253,7 @@ class MigrationRunner {
|
|
|
228
253
|
async createCheckpoint(migration, checkpoint) {
|
|
229
254
|
this.logger.info(checkpoint, `Saving checkpoint ${migration.getId()}`);
|
|
230
255
|
const execute = () => this.repository.createCheckpoint(migration.getId(), checkpoint);
|
|
231
|
-
await
|
|
256
|
+
await executeWithRetry(execute);
|
|
232
257
|
}
|
|
233
258
|
async getOrCreateRun() {
|
|
234
259
|
const resolvedStatus = ["done", "error"];
|
|
@@ -239,7 +264,7 @@ class MigrationRunner {
|
|
|
239
264
|
}
|
|
240
265
|
if (!lastRun || resolvedStatus.includes(lastRun.status)) {
|
|
241
266
|
lastRun = {
|
|
242
|
-
id:
|
|
267
|
+
id: mdbid(),
|
|
243
268
|
status: "init",
|
|
244
269
|
startedOn: getCurrentISOTime(),
|
|
245
270
|
finishedOn: "",
|
|
@@ -276,12 +301,33 @@ class MigrationRunner {
|
|
|
276
301
|
this.setRunItem(run, item);
|
|
277
302
|
await this.repository.saveRun(run);
|
|
278
303
|
}
|
|
304
|
+
printForceExecuteEnvVars() {
|
|
305
|
+
const forceKeys = Object.keys(process.env).filter(key => key.startsWith("WEBINY_MIGRATION_FORCE_EXECUTE_"));
|
|
306
|
+
if (!forceKeys.length) {
|
|
307
|
+
this.logger.info(`No migrations are enforced via WEBINY_MIGRATION_FORCE_EXECUTE environment variable.`);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
this.logger.info(`FORCED MIGRATIONS DETECTED!`);
|
|
311
|
+
for (const key of forceKeys) {
|
|
312
|
+
this.logger.info(`${key}=${process.env[key]}`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
printSkipExecuteEnvVars() {
|
|
316
|
+
const skipKeys = Object.keys(process.env).filter(key => key.startsWith("WEBINY_MIGRATION_SKIP_"));
|
|
317
|
+
if (!skipKeys.length) {
|
|
318
|
+
this.logger.info(`No migrations are skipped via WEBINY_MIGRATION_SKIP environment variable.`);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
this.logger.info(`SKIPPED MIGRATIONS DETECTED!`);
|
|
322
|
+
for (const key of skipKeys) {
|
|
323
|
+
this.logger.info(`${key}=${process.env[key]}`);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
279
326
|
}
|
|
280
|
-
|
|
281
|
-
(0, _ioc.makeInjectable)(MigrationRunner, [(0, _ioc.inject)(_symbols.MigrationRepositorySymbol), (0, _ioc.inject)(_symbols.ExecutionTimeLimiterSymbol), (0, _ioc.inject)(_symbols.MigrationSymbol, {
|
|
327
|
+
makeInjectable(MigrationRunner, [inject(MigrationRepositorySymbol), inject(ExecutionTimeLimiterSymbol), inject(MigrationSymbol, {
|
|
282
328
|
multi: true,
|
|
283
329
|
optional: true
|
|
284
|
-
}),
|
|
330
|
+
}), inject(LoggerSymbol, {
|
|
285
331
|
optional: true
|
|
286
332
|
})]);
|
|
287
333
|
|
package/MigrationRunner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_semver","require","_ioc","_utils","_symbols","_createPinoLogger","getCurrentISOTime","Date","toISOString","getRunItemDuration","runItem","startedOn","finishedOn","getTime","shouldForceExecute","mig","key","getId","replace","process","env","MigrationNotFinished","Error","MigrationInProgress","MigrationRunner","context","constructor","repository","timeLimiter","migrations","logger","createPinoLogger","setContext","execute","projectVersion","isApplicable","lastRun","getOrCreateRun","validateIds","err","status","error","message","saveRun","latestMigration","listMigrations","limit","info","currentVersion","coerce","startingId","id","lastId","logMigration","description","reason","defaultIsApplicable","isMigrationApplicable","executableMigrations","filter","setRunItem","sort","a","b","length","shouldCreateCheckpoint","migration","getOrCreateRunItem","checkpoint","getCheckpoint","getChildLogger","forceExecute","runningOutOfTime","createCheckpoint","data","createCheckpointAndExit","shouldExecute","setRunItemAndSave","getDescription","name","stack","code","deleteCheckpoint","getStatus","getLastRun","withDescriptions","map","dataMigration","find","dm","ids","Set","endsWith","has","add","executeWithRetry","resolvedStatus","unresolvedStatus","includes","mdbid","run","existingItem","item","index","findIndex","push","slice","exports","makeInjectable","inject","MigrationRepositorySymbol","ExecutionTimeLimiterSymbol","MigrationSymbol","multi","optional","LoggerSymbol"],"sources":["MigrationRunner.ts"],"sourcesContent":["import { coerce } from \"semver\";\nimport { Logger } from \"@webiny/logger\";\nimport { inject, makeInjectable } from \"@webiny/ioc\";\nimport { executeWithRetry, mdbid } from \"@webiny/utils\";\nimport {\n MigrationRepositorySymbol,\n LoggerSymbol,\n MigrationSymbol,\n ExecutionTimeLimiterSymbol\n} from \"./symbols\";\nimport { createPinoLogger, getChildLogger } from \"./createPinoLogger\";\nimport {\n MigrationRepository,\n DataMigration,\n DataMigrationContext,\n ExecutionTimeLimiter,\n MigrationRun,\n MigrationStatus,\n MigrationRunItem\n} from \"~/types\";\n\nexport type IsMigrationApplicable = (migration: DataMigration) => boolean;\n\nconst getCurrentISOTime = () => {\n return new Date().toISOString();\n};\n\nconst getRunItemDuration = (runItem: MigrationRunItem) => {\n if (!runItem.startedOn || !runItem.finishedOn) {\n return \"N/A\";\n }\n\n return new Date(runItem.finishedOn).getTime() - new Date(runItem.startedOn).getTime();\n};\n\nconst shouldForceExecute = (mig: DataMigration) => {\n const key = `WEBINY_MIGRATION_FORCE_EXECUTE_${mig.getId().replace(/[\\.\\-]/g, \"_\")}`;\n\n return process.env[key] === \"true\";\n};\n\nclass MigrationNotFinished extends Error {}\nclass MigrationInProgress extends Error {}\n\nexport class MigrationRunner {\n private readonly logger: Logger;\n private readonly migrations: DataMigration[];\n private readonly repository: MigrationRepository;\n private readonly timeLimiter: ExecutionTimeLimiter;\n private context: Record<string, any> = {};\n\n constructor(\n repository: MigrationRepository,\n timeLimiter: ExecutionTimeLimiter,\n migrations: DataMigration[],\n logger: Logger | undefined\n ) {\n this.repository = repository;\n this.timeLimiter = timeLimiter;\n this.migrations = migrations || [];\n\n if (!logger) {\n logger = createPinoLogger();\n }\n this.logger = logger;\n }\n\n setContext(context: Record<string, any>) {\n this.context = context;\n }\n\n async execute(projectVersion: string, isApplicable?: IsMigrationApplicable) {\n const lastRun = await this.getOrCreateRun();\n\n try {\n this.validateIds(this.migrations);\n } catch (err) {\n lastRun.status = \"error\";\n lastRun.error = {\n message: err.message\n };\n await this.repository.saveRun(lastRun);\n return;\n }\n\n const [latestMigration] = await this.repository.listMigrations({ limit: 1 });\n\n this.logger.info(`Project version is %s.`, projectVersion);\n\n // Get current version, and coerce it to a valid SemVer.\n // With this, we can run migrations targeted for stable versions, released under a preid tag (e.g., `beta`).\n const currentVersion = coerce(projectVersion) + \"\";\n const startingId = latestMigration ? latestMigration.id : `${currentVersion}-000`;\n const lastId = `${currentVersion}-999`;\n\n // Create initial migration record.\n if (!latestMigration) {\n this.logger.info(\n `No migrations were ever executed. Creating initial migration record %s.`,\n startingId\n );\n await this.repository.logMigration({\n id: startingId,\n description: \"starting point for applicable migrations detection\",\n startedOn: getCurrentISOTime(),\n finishedOn: getCurrentISOTime(),\n reason: \"initial migration\"\n });\n } else {\n this.logger.info(`Latest migration ID is %s.`, latestMigration.id);\n }\n\n if (isApplicable) {\n this.logger.info(`Using custom \"isApplicable\" function.`);\n } else {\n this.logger.info(`Using migrations in the range of %s to %s.`, startingId, lastId);\n }\n\n const defaultIsApplicable: IsMigrationApplicable = mig => {\n return mig.getId() > startingId && mig.getId() <= lastId;\n };\n\n const isMigrationApplicable = isApplicable || defaultIsApplicable;\n\n const executableMigrations = this.migrations\n .filter(mig => {\n if (shouldForceExecute(mig)) {\n return true;\n }\n\n if (!isMigrationApplicable(mig)) {\n this.setRunItem(lastRun, {\n id: mig.getId(),\n status: \"not-applicable\"\n });\n\n return false;\n }\n return true;\n })\n .sort((a, b) => (a.getId() > b.getId() ? 1 : -1));\n\n this.logger.info(\n `Found %s applicable out of %s available migration(s).`,\n executableMigrations.length,\n this.migrations.length\n );\n\n // Are we're within the last 2 minutes of the execution time limit?\n const shouldCreateCheckpoint = () => {\n return this.timeLimiter() < 120000;\n };\n\n //\n for (const migration of executableMigrations) {\n const runItem = this.getOrCreateRunItem(lastRun, migration);\n const checkpoint = await this.repository.getCheckpoint(migration.getId());\n const logger = getChildLogger(this.logger, migration);\n\n if (checkpoint) {\n this.logger.info(checkpoint, `Found checkpoint ${migration.getId()}.`);\n }\n\n const context: DataMigrationContext = {\n projectVersion,\n logger,\n checkpoint,\n forceExecute: shouldForceExecute(migration),\n runningOutOfTime: shouldCreateCheckpoint,\n createCheckpoint: async (data: unknown) => {\n await this.createCheckpoint(migration, data);\n },\n createCheckpointAndExit: async (data: unknown) => {\n await this.createCheckpoint(migration, data);\n // We throw an error to break out of the migration execution completely.\n throw new MigrationNotFinished();\n }\n };\n try {\n const shouldExecute =\n checkpoint || shouldForceExecute(migration)\n ? true\n : await migration.shouldExecute(context);\n\n if (!shouldExecute) {\n this.logger.info(`Skipping migration %s.`, migration.getId());\n runItem.status = \"skipped\";\n\n await this.setRunItemAndSave(lastRun, runItem);\n\n await this.repository.logMigration({\n id: migration.getId(),\n description: migration.getDescription(),\n reason: \"skipped\"\n });\n\n continue;\n }\n\n lastRun.status = \"running\";\n runItem.status = \"running\";\n if (!runItem.startedOn) {\n runItem.startedOn = getCurrentISOTime();\n }\n await this.setRunItemAndSave(lastRun, runItem);\n this.logger.info(\n `Executing migration %s: %s`,\n migration.getId(),\n migration.getDescription()\n );\n await migration.execute(context);\n runItem.status = \"done\";\n } catch (err) {\n // If `MigrationNotFinished` was thrown, we will need to resume the migration.\n if (err instanceof MigrationNotFinished) {\n lastRun.status = \"pending\";\n runItem.status = \"pending\";\n return;\n }\n\n runItem.status = \"error\";\n lastRun.status = \"error\";\n lastRun.error = {\n name: err.name || \"Migration error\",\n message: err.message,\n stack: err.stack,\n data: err.data,\n code: err.code\n };\n this.logger.error(err, err.message);\n return;\n } finally {\n // We sum duration from the previous run with the current run.\n runItem.finishedOn = getCurrentISOTime();\n\n // Update run stats.\n await this.setRunItemAndSave(lastRun, runItem);\n\n this.logger.info(\n `Finished executing migration %s in %sms.`,\n migration.getId(),\n getRunItemDuration(runItem)\n );\n }\n\n await this.repository.logMigration({\n id: migration.getId(),\n description: migration.getDescription(),\n startedOn: runItem.startedOn,\n finishedOn: runItem.finishedOn,\n reason: \"executed\"\n });\n\n this.logger.info(`Deleting checkpoint ${migration.getId()}.`);\n await this.repository.deleteCheckpoint(migration.getId());\n }\n\n lastRun.status = \"done\";\n lastRun.finishedOn = getCurrentISOTime();\n await this.repository.saveRun(lastRun);\n\n this.logger.info(`Finished processing applicable migrations.`);\n }\n\n async getStatus(): Promise<MigrationStatus> {\n const lastRun = await this.repository.getLastRun();\n if (!lastRun) {\n throw new Error(`No migrations were ever executed!`);\n }\n\n // Since we don't store migration descriptions to DB, we need to fetch them from actual migration objects.\n const withDescriptions = lastRun.migrations.map(mig => {\n const dataMigration = this.migrations.find(dm => dm.getId() === mig.id);\n return {\n ...mig,\n description: dataMigration ? dataMigration.getDescription() : \"N/A\"\n };\n });\n\n return { ...lastRun, migrations: withDescriptions };\n }\n\n private validateIds(migrations: DataMigration[]) {\n const ids = new Set();\n for (const mig of migrations) {\n const id = mig.getId();\n if (id.endsWith(\"-000\")) {\n const error = new Error(`Migration ID must not end with \"000\": ${id}`);\n this.logger.error(error);\n throw error;\n }\n\n if (ids.has(id)) {\n const error = new Error(`Duplicate migration ID found: ${id}`);\n this.logger.error(error);\n throw error;\n }\n ids.add(id);\n }\n }\n\n private async createCheckpoint(migration: DataMigration, checkpoint: unknown) {\n this.logger.info(checkpoint, `Saving checkpoint ${migration.getId()}`);\n const execute = () => this.repository.createCheckpoint(migration.getId(), checkpoint);\n await executeWithRetry(execute);\n }\n\n private async getOrCreateRun() {\n const resolvedStatus: Array<MigrationRun[\"status\"]> = [\"done\", \"error\"];\n const unresolvedStatus: Array<MigrationRun[\"status\"]> = [\"init\", \"running\"];\n\n let lastRun = await this.repository.getLastRun();\n\n if (lastRun && unresolvedStatus.includes(lastRun.status)) {\n throw new MigrationInProgress(`Migration is already in progress (ID: ${lastRun.id})!`);\n }\n\n if (!lastRun || resolvedStatus.includes(lastRun.status)) {\n lastRun = {\n id: mdbid(),\n status: \"init\",\n startedOn: getCurrentISOTime(),\n finishedOn: \"\",\n migrations: [],\n context: this.context\n };\n\n await this.repository.saveRun(lastRun);\n }\n\n return lastRun;\n }\n\n private getOrCreateRunItem(run: MigrationRun, migration: DataMigration): MigrationRunItem {\n const existingItem = run.migrations.find(item => item.id === migration.getId());\n if (existingItem) {\n return {\n ...existingItem,\n status: \"running\"\n };\n }\n\n return {\n id: migration.getId(),\n status: \"running\"\n };\n }\n\n private setRunItem(run: MigrationRun, item: MigrationRunItem) {\n const index = run.migrations.findIndex(runItem => runItem.id === item.id);\n if (index < 0) {\n run.migrations.push(item);\n } else {\n run.migrations = [\n ...run.migrations.slice(0, index),\n item,\n ...run.migrations.slice(index + 1)\n ];\n }\n\n run.migrations = run.migrations.sort((a, b) => (a.id > b.id ? 1 : -1));\n }\n\n private async setRunItemAndSave(run: MigrationRun, item: MigrationRunItem) {\n this.setRunItem(run, item);\n await this.repository.saveRun(run);\n }\n}\n\nmakeInjectable(MigrationRunner, [\n inject(MigrationRepositorySymbol),\n inject(ExecutionTimeLimiterSymbol),\n inject(MigrationSymbol, { multi: true, optional: true }),\n inject(LoggerSymbol, { optional: true })\n]);\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAMA,IAAAI,iBAAA,GAAAJ,OAAA;AAaA,MAAMK,iBAAiB,GAAGA,CAAA,KAAM;EAC5B,OAAO,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;AACnC,CAAC;AAED,MAAMC,kBAAkB,GAAIC,OAAyB,IAAK;EACtD,IAAI,CAACA,OAAO,CAACC,SAAS,IAAI,CAACD,OAAO,CAACE,UAAU,EAAE;IAC3C,OAAO,KAAK;EAChB;EAEA,OAAO,IAAIL,IAAI,CAACG,OAAO,CAACE,UAAU,CAAC,CAACC,OAAO,CAAC,CAAC,GAAG,IAAIN,IAAI,CAACG,OAAO,CAACC,SAAS,CAAC,CAACE,OAAO,CAAC,CAAC;AACzF,CAAC;AAED,MAAMC,kBAAkB,GAAIC,GAAkB,IAAK;EAC/C,MAAMC,GAAG,GAAI,kCAAiCD,GAAG,CAACE,KAAK,CAAC,CAAC,CAACC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAE,EAAC;EAEnF,OAAOC,OAAO,CAACC,GAAG,CAACJ,GAAG,CAAC,KAAK,MAAM;AACtC,CAAC;AAED,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,GAAG,CAACvE,UAAU,CAAC6E,KAAK,CAACH,KAAK,GAAG,CAAC,CAAC,CACrC;IACL;IAEAH,GAAG,CAACvE,UAAU,GAAGuE,GAAG,CAACvE,UAAU,CAACgC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAMD,CAAC,CAACX,EAAE,GAAGY,CAAC,CAACZ,EAAE,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC;EAC1E;EAEA,MAAc0B,iBAAiBA,CAACuB,GAAiB,EAAEE,IAAsB,EAAE;IACvE,IAAI,CAAC1C,UAAU,CAACwC,GAAG,EAAEE,IAAI,CAAC;IAC1B,MAAM,IAAI,CAAC3E,UAAU,CAACgB,OAAO,CAACyD,GAAG,CAAC;EACtC;AACJ;AAACO,OAAA,CAAAnF,eAAA,GAAAA,eAAA;AAED,IAAAoF,mBAAc,EAACpF,eAAe,EAAE,CAC5B,IAAAqF,WAAM,EAACC,kCAAyB,CAAC,EACjC,IAAAD,WAAM,EAACE,mCAA0B,CAAC,EAClC,IAAAF,WAAM,EAACG,wBAAe,EAAE;EAAEC,KAAK,EAAE,IAAI;EAAEC,QAAQ,EAAE;AAAK,CAAC,CAAC,EACxD,IAAAL,WAAM,EAACM,qBAAY,EAAE;EAAED,QAAQ,EAAE;AAAK,CAAC,CAAC,CAC3C,CAAC"}
|
|
1
|
+
{"version":3,"names":["coerce","inject","makeInjectable","executeWithRetry","mdbid","MigrationRepositorySymbol","LoggerSymbol","MigrationSymbol","ExecutionTimeLimiterSymbol","createPinoLogger","getChildLogger","getCurrentISOTime","Date","toISOString","getRunItemDuration","runItem","startedOn","finishedOn","getTime","shouldForceExecute","mig","key","getId","replace","process","env","shouldSkip","MigrationNotFinished","Error","MigrationInProgress","MigrationRunner","context","constructor","repository","timeLimiter","migrations","logger","setContext","execute","projectVersion","isApplicable","forceExecute","lastRun","getOrCreateRun","validateIds","err","status","error","message","saveRun","latestMigration","listMigrations","limit","info","currentVersion","startingId","id","lastId","logMigration","description","reason","defaultIsApplicable","isMigrationApplicable","printForceExecuteEnvVars","printSkipExecuteEnvVars","executableMigrations","filter","setRunItem","sort","a","b","length","shouldCreateCheckpoint","migration","getOrCreateRunItem","checkpoint","getCheckpoint","runningOutOfTime","createCheckpoint","data","createCheckpointAndExit","shouldExecute","setRunItemAndSave","getDescription","name","stack","code","deleteCheckpoint","getStatus","getLastRun","withDescriptions","map","dataMigration","find","dm","ids","Set","endsWith","has","add","resolvedStatus","unresolvedStatus","includes","run","existingItem","item","index","findIndex","push","slice","forceKeys","Object","keys","startsWith","skipKeys","multi","optional"],"sources":["MigrationRunner.ts"],"sourcesContent":["import { coerce } from \"semver\";\nimport type { Logger } from \"@webiny/logger\";\nimport { inject, makeInjectable } from \"@webiny/ioc\";\nimport { executeWithRetry, mdbid } from \"@webiny/utils\";\nimport {\n MigrationRepositorySymbol,\n LoggerSymbol,\n MigrationSymbol,\n ExecutionTimeLimiterSymbol\n} from \"./symbols.js\";\nimport { createPinoLogger, getChildLogger } from \"./createPinoLogger.js\";\nimport type {\n MigrationRepository,\n DataMigration,\n DataMigrationContext,\n ExecutionTimeLimiter,\n MigrationRun,\n MigrationStatus,\n MigrationRunItem\n} from \"~/types.js\";\n\nexport type IsMigrationApplicable = (migration: DataMigration) => boolean;\n\nconst getCurrentISOTime = () => {\n return new Date().toISOString();\n};\n\nconst getRunItemDuration = (runItem: MigrationRunItem) => {\n if (!runItem.startedOn || !runItem.finishedOn) {\n return \"N/A\";\n }\n\n return new Date(runItem.finishedOn).getTime() - new Date(runItem.startedOn).getTime();\n};\n\n/**\n * This allows us to force-execute a migration, even if it's not in the list of the applicable migrations.\n * Example: WEBINY_MIGRATION_FORCE_EXECUTE_5_35_0_006=true\n */\nconst shouldForceExecute = (mig: DataMigration) => {\n const key = `WEBINY_MIGRATION_FORCE_EXECUTE_${mig.getId().replace(/[\\.\\-]/g, \"_\")}`;\n\n return process.env[key] === \"true\";\n};\n\n/**\n * This allows us to always skip a migration.\n * Example: WEBINY_MIGRATION_SKIP_5_35_0_006=true\n */\nconst shouldSkip = (mig: DataMigration) => {\n const key = `WEBINY_MIGRATION_SKIP_${mig.getId().replace(/[\\.\\-]/g, \"_\")}`;\n\n return process.env[key] === \"true\";\n};\n\nclass MigrationNotFinished extends Error {}\nclass MigrationInProgress extends Error {}\n\nexport class MigrationRunner {\n private readonly logger: Logger;\n private readonly migrations: DataMigration[];\n private readonly repository: MigrationRepository;\n private readonly timeLimiter: ExecutionTimeLimiter;\n private context: Record<string, any> = {};\n\n constructor(\n repository: MigrationRepository,\n timeLimiter: ExecutionTimeLimiter,\n migrations: DataMigration[],\n logger: Logger | undefined\n ) {\n this.repository = repository;\n this.timeLimiter = timeLimiter;\n this.migrations = migrations || [];\n\n if (!logger) {\n logger = createPinoLogger();\n }\n this.logger = logger;\n }\n\n setContext(context: Record<string, any>) {\n this.context = context;\n }\n\n async execute(\n projectVersion: string,\n isApplicable?: IsMigrationApplicable,\n // Force execute applicable migrations.\n forceExecute = false\n ) {\n const lastRun = await this.getOrCreateRun();\n\n try {\n this.validateIds(this.migrations);\n } catch (err) {\n lastRun.status = \"error\";\n lastRun.error = {\n message: err.message\n };\n await this.repository.saveRun(lastRun);\n return;\n }\n\n const [latestMigration] = await this.repository.listMigrations({ limit: 1 });\n\n this.logger.info(`Project version is %s.`, projectVersion);\n\n // Get current version, and coerce it to a valid SemVer.\n // With this, we can run migrations targeted for stable versions, released under a preid tag (e.g., `beta`).\n const currentVersion = coerce(projectVersion) + \"\";\n const startingId = latestMigration ? latestMigration.id : `${currentVersion}-000`;\n const lastId = `${currentVersion}-999`;\n\n // Create initial migration record.\n if (!latestMigration) {\n this.logger.info(\n `No migrations were ever executed. Creating initial migration record %s.`,\n startingId\n );\n await this.repository.logMigration({\n id: startingId,\n description: \"starting point for applicable migrations detection\",\n startedOn: getCurrentISOTime(),\n finishedOn: getCurrentISOTime(),\n reason: \"initial migration\"\n });\n } else {\n this.logger.info(`Latest migration ID is %s.`, latestMigration.id);\n }\n\n if (isApplicable) {\n this.logger.info(`Using custom \"isApplicable\" function.`);\n } else {\n this.logger.info(`Using migrations in the range of %s to %s.`, startingId, lastId);\n }\n\n const defaultIsApplicable: IsMigrationApplicable = mig => {\n return mig.getId() > startingId && mig.getId() <= lastId;\n };\n\n const isMigrationApplicable = isApplicable || defaultIsApplicable;\n\n this.printForceExecuteEnvVars();\n this.printSkipExecuteEnvVars();\n\n if (forceExecute) {\n this.logger.info(\n `ALL APPLICABLE MIGRATIONS WILL BE FORCE-EXECUTED! (via --force flag)`\n );\n }\n\n const executableMigrations = this.migrations\n .filter(mig => {\n if (shouldSkip(mig)) {\n this.setRunItem(lastRun, {\n id: mig.getId(),\n status: \"skipped\"\n });\n\n return false;\n }\n\n if (shouldForceExecute(mig)) {\n return true;\n }\n\n if (!isMigrationApplicable(mig)) {\n this.setRunItem(lastRun, {\n id: mig.getId(),\n status: \"not-applicable\"\n });\n\n return false;\n }\n return true;\n })\n .sort((a, b) => (a.getId() > b.getId() ? 1 : -1));\n\n this.logger.info(\n `Found %s applicable out of %s available migration(s).`,\n executableMigrations.length,\n this.migrations.length\n );\n\n // Are we're within the last 2 minutes of the execution time limit?\n const shouldCreateCheckpoint = () => {\n return this.timeLimiter() < 120000;\n };\n\n //\n for (const migration of executableMigrations) {\n const runItem = this.getOrCreateRunItem(lastRun, migration);\n const checkpoint = await this.repository.getCheckpoint(migration.getId());\n const logger = getChildLogger(this.logger, migration);\n\n if (checkpoint) {\n this.logger.info(checkpoint, `Found checkpoint ${migration.getId()}.`);\n }\n\n const context: DataMigrationContext = {\n projectVersion,\n logger,\n checkpoint,\n forceExecute: forceExecute || shouldForceExecute(migration),\n runningOutOfTime: shouldCreateCheckpoint,\n createCheckpoint: async (data: unknown) => {\n await this.createCheckpoint(migration, data);\n },\n createCheckpointAndExit: async (data: unknown) => {\n await this.createCheckpoint(migration, data);\n // We throw an error to break out of the migration execution completely.\n throw new MigrationNotFinished();\n }\n };\n try {\n const shouldExecute =\n checkpoint || context.forceExecute\n ? true\n : await migration.shouldExecute(context);\n\n if (!shouldExecute) {\n this.logger.info(`Skipping migration %s.`, migration.getId());\n runItem.status = \"skipped\";\n\n await this.setRunItemAndSave(lastRun, runItem);\n\n await this.repository.logMigration({\n id: migration.getId(),\n description: migration.getDescription(),\n reason: \"skipped\"\n });\n\n continue;\n }\n\n lastRun.status = \"running\";\n runItem.status = \"running\";\n if (!runItem.startedOn) {\n runItem.startedOn = getCurrentISOTime();\n }\n await this.setRunItemAndSave(lastRun, runItem);\n this.logger.info(\n `Executing migration %s: %s`,\n migration.getId(),\n migration.getDescription()\n );\n await migration.execute(context);\n runItem.status = \"done\";\n } catch (err) {\n // If `MigrationNotFinished` was thrown, we will need to resume the migration.\n if (err instanceof MigrationNotFinished) {\n lastRun.status = \"pending\";\n runItem.status = \"pending\";\n return;\n }\n\n runItem.status = \"error\";\n lastRun.status = \"error\";\n lastRun.error = {\n name: err.name || \"Migration error\",\n message: err.message,\n stack: err.stack,\n data: err.data,\n code: err.code\n };\n this.logger.error(err, err.message);\n return;\n } finally {\n runItem.finishedOn = getCurrentISOTime();\n\n // Update run stats.\n await this.setRunItemAndSave(lastRun, runItem);\n\n if (runItem.status === \"pending\") {\n this.logger.info(\n `Pausing migration %s, awaiting continuation.`,\n migration.getId()\n );\n } else {\n this.logger.info(\n `Finished executing migration %s in %sms.`,\n migration.getId(),\n getRunItemDuration(runItem)\n );\n }\n }\n\n await this.repository.logMigration({\n id: migration.getId(),\n description: migration.getDescription(),\n startedOn: runItem.startedOn,\n finishedOn: runItem.finishedOn,\n reason: \"executed\"\n });\n\n this.logger.info(`Deleting checkpoint ${migration.getId()}.`);\n await this.repository.deleteCheckpoint(migration.getId());\n }\n\n lastRun.status = \"done\";\n lastRun.finishedOn = getCurrentISOTime();\n await this.repository.saveRun(lastRun);\n\n this.logger.info(`Finished processing applicable migrations.`);\n }\n\n async getStatus(): Promise<MigrationStatus> {\n const lastRun = await this.repository.getLastRun();\n if (!lastRun) {\n throw new Error(`No migrations were ever executed!`);\n }\n\n // Since we don't store migration descriptions to DB, we need to fetch them from actual migration objects.\n const withDescriptions = lastRun.migrations.map(mig => {\n const dataMigration = this.migrations.find(dm => dm.getId() === mig.id);\n return {\n ...mig,\n description: dataMigration ? dataMigration.getDescription() : \"N/A\"\n };\n });\n\n return { ...lastRun, migrations: withDescriptions };\n }\n\n private validateIds(migrations: DataMigration[]) {\n const ids = new Set();\n for (const mig of migrations) {\n const id = mig.getId();\n if (id.endsWith(\"-000\")) {\n const error = new Error(`Migration ID must not end with \"000\": ${id}`);\n this.logger.error(error);\n throw error;\n }\n\n if (ids.has(id)) {\n const error = new Error(`Duplicate migration ID found: ${id}`);\n this.logger.error(error);\n throw error;\n }\n ids.add(id);\n }\n }\n\n private async createCheckpoint(migration: DataMigration, checkpoint: unknown) {\n this.logger.info(checkpoint, `Saving checkpoint ${migration.getId()}`);\n const execute = () => this.repository.createCheckpoint(migration.getId(), checkpoint);\n await executeWithRetry(execute);\n }\n\n private async getOrCreateRun() {\n const resolvedStatus: Array<MigrationRun[\"status\"]> = [\"done\", \"error\"];\n const unresolvedStatus: Array<MigrationRun[\"status\"]> = [\"init\", \"running\"];\n\n let lastRun = await this.repository.getLastRun();\n\n if (lastRun && unresolvedStatus.includes(lastRun.status)) {\n throw new MigrationInProgress(`Migration is already in progress (ID: ${lastRun.id})!`);\n }\n\n if (!lastRun || resolvedStatus.includes(lastRun.status)) {\n lastRun = {\n id: mdbid(),\n status: \"init\",\n startedOn: getCurrentISOTime(),\n finishedOn: \"\",\n migrations: [],\n context: this.context\n };\n\n await this.repository.saveRun(lastRun);\n }\n\n return lastRun;\n }\n\n private getOrCreateRunItem(run: MigrationRun, migration: DataMigration): MigrationRunItem {\n const existingItem = run.migrations.find(item => item.id === migration.getId());\n if (existingItem) {\n return {\n ...existingItem,\n status: \"running\"\n };\n }\n\n return {\n id: migration.getId(),\n status: \"running\"\n };\n }\n\n private setRunItem(run: MigrationRun, item: MigrationRunItem) {\n const index = run.migrations.findIndex(runItem => runItem.id === item.id);\n if (index < 0) {\n run.migrations.push(item);\n } else {\n run.migrations = [\n ...run.migrations.slice(0, index),\n item,\n ...run.migrations.slice(index + 1)\n ];\n }\n\n run.migrations = run.migrations.sort((a, b) => (a.id > b.id ? 1 : -1));\n }\n\n private async setRunItemAndSave(run: MigrationRun, item: MigrationRunItem) {\n this.setRunItem(run, item);\n await this.repository.saveRun(run);\n }\n\n private printForceExecuteEnvVars() {\n const forceKeys = Object.keys(process.env).filter(key =>\n key.startsWith(\"WEBINY_MIGRATION_FORCE_EXECUTE_\")\n );\n\n if (!forceKeys.length) {\n this.logger.info(\n `No migrations are enforced via WEBINY_MIGRATION_FORCE_EXECUTE environment variable.`\n );\n\n return;\n }\n\n this.logger.info(`FORCED MIGRATIONS DETECTED!`);\n for (const key of forceKeys) {\n this.logger.info(`${key}=${process.env[key]}`);\n }\n }\n\n private printSkipExecuteEnvVars() {\n const skipKeys = Object.keys(process.env).filter(key =>\n key.startsWith(\"WEBINY_MIGRATION_SKIP_\")\n );\n\n if (!skipKeys.length) {\n this.logger.info(\n `No migrations are skipped via WEBINY_MIGRATION_SKIP environment variable.`\n );\n\n return;\n }\n\n this.logger.info(`SKIPPED MIGRATIONS DETECTED!`);\n for (const key of skipKeys) {\n this.logger.info(`${key}=${process.env[key]}`);\n }\n }\n}\n\nmakeInjectable(MigrationRunner, [\n inject(MigrationRepositorySymbol),\n inject(ExecutionTimeLimiterSymbol),\n inject(MigrationSymbol, { multi: true, optional: true }),\n inject(LoggerSymbol, { optional: true })\n]);\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,QAAQ;AAE/B,SAASC,MAAM,EAAEC,cAAc,QAAQ,aAAa;AACpD,SAASC,gBAAgB,EAAEC,KAAK,QAAQ,eAAe;AACvD,SACIC,yBAAyB,EACzBC,YAAY,EACZC,eAAe,EACfC,0BAA0B;AAE9B,SAASC,gBAAgB,EAAEC,cAAc;AAazC,MAAMC,iBAAiB,GAAGA,CAAA,KA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B,MAAMkD,QAAQ,GAAGH,MAAM,CAACC,IAAI,CAACxF,OAAO,CAACC,GAAG,CAAC,CAACyC,MAAM,CAAC7C,GAAG,IAChDA,GAAG,CAAC4F,UAAU,CAAC,wBAAwB,CAC3C,CAAC;IAED,IAAI,CAACC,QAAQ,CAAC3C,MAAM,EAAE;MAClB,IAAI,CAACnC,MAAM,CAACiB,IAAI,CACZ,2EACJ,CAAC;MAED;IACJ;IAEA,IAAI,CAACjB,MAAM,CAACiB,IAAI,CAAC,8BAA8B,CAAC;IAChD,KAAK,MAAMhC,GAAG,IAAI6F,QAAQ,EAAE;MACxB,IAAI,CAAC9E,MAAM,CAACiB,IAAI,CAAC,GAAGhC,GAAG,IAAIG,OAAO,CAACC,GAAG,CAACJ,GAAG,CAAC,EAAE,CAAC;IAClD;EACJ;AACJ;AAEAnB,cAAc,CAAC4B,eAAe,EAAE,CAC5B7B,MAAM,CAACI,yBAAyB,CAAC,EACjCJ,MAAM,CAACO,0BAA0B,CAAC,EAClCP,MAAM,CAACM,eAAe,EAAE;EAAE4G,KAAK,EAAE,IAAI;EAAEC,QAAQ,EAAE;AAAK,CAAC,CAAC,EACxDnH,MAAM,CAACK,YAAY,EAAE;EAAE8G,QAAQ,EAAE;AAAK,CAAC,CAAC,CAC3C,CAAC","ignoreList":[]}
|
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# @webiny/data-migration
|
|
2
2
|
|
|
3
|
-
[!
|
|
4
|
-
[
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { MigrationRunnerResult, MigrationRunReporter } from ".";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { MigrationRunnerResult, MigrationRunReporter } from "../cli/index.js";
|
|
2
|
+
import type { LogReporter } from "../cli/index.js";
|
|
3
|
+
import { UiService } from "@webiny/project/abstractions/index.js";
|
|
4
|
+
export interface CliMigrationRunReporterDi {
|
|
5
|
+
uiService: UiService.Interface;
|
|
6
|
+
}
|
|
4
7
|
export declare class CliMigrationRunReporter implements MigrationRunReporter {
|
|
5
|
-
private
|
|
8
|
+
private di;
|
|
6
9
|
private logReporter;
|
|
7
|
-
constructor(logReporter: LogReporter,
|
|
10
|
+
constructor(logReporter: LogReporter, di: CliMigrationRunReporterDi);
|
|
8
11
|
report(result: MigrationRunnerResult): Promise<void>;
|
|
9
12
|
private makeEven;
|
|
10
13
|
}
|
|
@@ -1,43 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.CliMigrationRunReporter = void 0;
|
|
8
|
-
var _centerAlign = _interopRequireDefault(require("center-align"));
|
|
9
|
-
class CliMigrationRunReporter {
|
|
10
|
-
constructor(logReporter, context) {
|
|
1
|
+
import center from "center-align";
|
|
2
|
+
export class CliMigrationRunReporter {
|
|
3
|
+
constructor(logReporter, di) {
|
|
11
4
|
this.logReporter = logReporter;
|
|
12
|
-
this.
|
|
5
|
+
this.di = di;
|
|
13
6
|
}
|
|
14
7
|
report(result) {
|
|
8
|
+
const {
|
|
9
|
+
uiService: ui
|
|
10
|
+
} = this.di;
|
|
15
11
|
result.onSuccess(data => {
|
|
16
12
|
const functionName = result.getFunctionName().split(":").pop();
|
|
17
13
|
process.stdout.write("\n");
|
|
18
|
-
|
|
14
|
+
ui.success(`Data migration Lambda %s executed successfully!`, functionName);
|
|
19
15
|
const {
|
|
20
16
|
migrations,
|
|
21
17
|
...run
|
|
22
18
|
} = data;
|
|
23
19
|
if (!migrations.length) {
|
|
24
|
-
|
|
20
|
+
ui.info(`No applicable migrations were found!`);
|
|
25
21
|
return;
|
|
26
22
|
}
|
|
27
23
|
const maxLength = Math.max(...migrations.map(mig => mig.status.length)) + 2;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
ui.info(`Migration run: %s`, run.id);
|
|
25
|
+
ui.info(`Status: %s`, run.status);
|
|
26
|
+
ui.info(`Started on: %s`, run.startedOn);
|
|
31
27
|
if (run.status === "done") {
|
|
32
|
-
|
|
28
|
+
ui.info(`Finished on: %s`, run.finishedOn);
|
|
33
29
|
}
|
|
34
30
|
for (const migration of migrations) {
|
|
35
|
-
|
|
31
|
+
ui.info(...[`[%s] %s: ${migration.description}`, center(this.makeEven(migration.status), maxLength), migration.id]);
|
|
36
32
|
}
|
|
37
33
|
this.logReporter.printLogStreamLinks();
|
|
38
34
|
});
|
|
39
35
|
result.onError(error => {
|
|
40
|
-
|
|
36
|
+
ui.error(error.message);
|
|
41
37
|
});
|
|
42
38
|
|
|
43
39
|
// Process the result!
|
|
@@ -50,6 +46,5 @@ class CliMigrationRunReporter {
|
|
|
50
46
|
return str;
|
|
51
47
|
}
|
|
52
48
|
}
|
|
53
|
-
exports.CliMigrationRunReporter = CliMigrationRunReporter;
|
|
54
49
|
|
|
55
50
|
//# sourceMappingURL=CliMigrationRunReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["center","CliMigrationRunReporter","constructor","logReporter","di","report","result","uiService","ui","onSuccess","data","functionName","getFunctionName","split","pop","process","stdout","write","success","migrations","run","length","info","maxLength","Math","max","map","mig","status","id","startedOn","finishedOn","migration","description","makeEven","printLogStreamLinks","onError","error","message","str"],"sources":["CliMigrationRunReporter.ts"],"sourcesContent":["import type { MigrationRunnerResult, MigrationRunReporter } from \"~/cli/index.js\";\nimport center from \"center-align\";\nimport type { LogReporter } from \"~/cli/index.js\";\nimport { UiService } from \"@webiny/project/abstractions/index.js\";\n\nexport interface CliMigrationRunReporterDi {\n uiService: UiService.Interface;\n}\n\nexport class CliMigrationRunReporter implements MigrationRunReporter {\n private di: {\n uiService: UiService.Interface;\n };\n private logReporter: LogReporter;\n\n constructor(logReporter: LogReporter, di: CliMigrationRunReporterDi) {\n this.logReporter = logReporter;\n this.di = di;\n }\n\n report(result: MigrationRunnerResult): Promise<void> {\n const { uiService: ui } = this.di;\n\n result.onSuccess(data => {\n const functionName = result.getFunctionName().split(\":\").pop();\n process.stdout.write(\"\\n\");\n ui.success(`Data migration Lambda %s executed successfully!`, functionName);\n\n const { migrations, ...run } = data;\n if (!migrations.length) {\n ui.info(`No applicable migrations were found!`);\n return;\n }\n\n const maxLength = Math.max(...migrations.map(mig => mig.status.length)) + 2;\n ui.info(`Migration run: %s`, run.id);\n ui.info(`Status: %s`, run.status);\n ui.info(`Started on: %s`, run.startedOn);\n if (run.status === \"done\") {\n ui.info(`Finished on: %s`, run.finishedOn);\n }\n for (const migration of migrations) {\n ui.info(\n ...[\n `[%s] %s: ${migration.description}`,\n center(this.makeEven(migration.status), maxLength),\n migration.id\n ]\n );\n }\n\n this.logReporter.printLogStreamLinks();\n });\n\n result.onError(error => {\n ui.error(error.message);\n });\n\n // Process the result!\n return result.process();\n }\n\n private makeEven(str: string) {\n if (str.length % 2 > 0) {\n return str + \" \";\n }\n return str;\n }\n}\n"],"mappings":"AACA,OAAOA,MAAM,MAAM,cAAc;AAQjC,OAAO,MAAMC,uBAAuB,CAAiC;EAMjEC,WAAWA,CAACC,WAAwB,EAAEC,EAA6B,EAAE;IACjE,IAAI,CAACD,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACC,EAAE,GAAGA,EAAE;EAChB;EAEAC,MAAMA,CAACC,MAA6B,EAAiB;IACjD,MAAM;MAAEC,SAAS,EAAEC;IAAG,CAAC,GAAG,IAAI,CAACJ,EAAE;IAEjCE,MAAM,CAACG,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CAAC;IAEF7B,MAAM,CAAC8B,OAAO,CAACC,KAAK,IAAI;MACpB7B,EAAE,CAAC6B,KAAK,CAACA,KAAK,CAACC,OAAO,CAAC;IAC3B,CAAC,CAAC;;IAEF;IACA,OAAOhC,MAAM,CAACS,OAAO,CAAC,CAAC;EAC3B;EAEQmB,QAAQA,CAACK,GAAW,EAAE;IAC1B,IAAIA,GAAG,CAAClB,MAAM,GAAG,CAAC,GAAG,CAAC,EAAE;MACpB,OAAOkB,GAAG,GAAG,GAAG;IACpB;IACA,OAAOA,GAAG;EACd;AACJ","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MigrationStatusReporter } from "
|
|
2
|
-
import { MigrationStatus } from "../types";
|
|
3
|
-
import { LogReporter } from "
|
|
1
|
+
import type { MigrationStatusReporter } from "../cli/MigrationStatusReporter.js";
|
|
2
|
+
import type { MigrationStatus } from "../types.js";
|
|
3
|
+
import type { LogReporter } from "../cli/LogReporter.js";
|
|
4
4
|
export declare class InteractiveCliStatusReporter implements MigrationStatusReporter {
|
|
5
5
|
private logReporter;
|
|
6
6
|
private firstCall;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.InteractiveCliStatusReporter = void 0;
|
|
8
|
-
var _readline = _interopRequireDefault(require("readline"));
|
|
9
|
-
class InteractiveCliStatusReporter {
|
|
1
|
+
import readline from "readline";
|
|
2
|
+
export class InteractiveCliStatusReporter {
|
|
10
3
|
firstCall = true;
|
|
11
4
|
constructor(logReporter) {
|
|
12
5
|
this.logReporter = logReporter;
|
|
@@ -55,8 +48,8 @@ class InteractiveCliStatusReporter {
|
|
|
55
48
|
this.firstCall = false;
|
|
56
49
|
}
|
|
57
50
|
clearLine() {
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
readline.clearLine(process.stdout, 0);
|
|
52
|
+
readline.cursorTo(process.stdout, 0);
|
|
60
53
|
}
|
|
61
54
|
getDuration(since) {
|
|
62
55
|
const ms = new Date().getTime() - new Date(since).getTime();
|
|
@@ -69,6 +62,5 @@ class InteractiveCliStatusReporter {
|
|
|
69
62
|
return minutes ? `${minutes}m ${seconds}s` : `${seconds}s`;
|
|
70
63
|
}
|
|
71
64
|
}
|
|
72
|
-
exports.InteractiveCliStatusReporter = InteractiveCliStatusReporter;
|
|
73
65
|
|
|
74
66
|
//# sourceMappingURL=InteractiveCliStatusReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["readline","InteractiveCliStatusReporter","firstCall","constructor","logReporter","console","log","report","migrationStatus","status","migrations","context","clearLine","currentLogStreamName","logStreamName","initializeStream","printLogStreamLinks","process","stdout","write","printLogs","currentMigration","find","mig","duration","getDuration","String","startedOn","id","includes","Promise","resolve","setTimeout","cursorTo","since","ms","Date","getTime","seconds","Math","floor","minutes","undefined"],"sources":["InteractiveCliStatusReporter.ts"],"sourcesContent":["import readline from \"readline\";\nimport type { MigrationStatusReporter } from \"~/cli/MigrationStatusReporter.js\";\nimport type { MigrationStatus } from \"~/types.js\";\nimport type { LogReporter } from \"~/cli/LogReporter.js\";\n\nexport class InteractiveCliStatusReporter implements MigrationStatusReporter {\n private logReporter: LogReporter;\n private firstCall = true;\n\n constructor(logReporter: LogReporter) {\n this.logReporter = logReporter;\n console.log(`Using \"InteractiveCliStatusReporter\".`);\n }\n\n async report(migrationStatus: MigrationStatus) {\n const { status, migrations, context } = migrationStatus;\n this.clearLine();\n\n const currentLogStreamName = context?.logStreamName;\n if (currentLogStreamName) {\n this.logReporter.initializeStream(currentLogStreamName);\n if (this.firstCall) {\n this.logReporter.printLogStreamLinks();\n process.stdout.write(`\\n---------- MIGRATION LOGS START ----------\\n\\n`);\n }\n await this.logReporter.printLogs(currentLogStreamName);\n }\n\n if (status === \"running\") {\n const currentMigration = migrations.find(mig => mig.status === \"running\");\n if (currentMigration) {\n const duration = this.getDuration(String(currentMigration.startedOn));\n process.stdout.write(\n `Running data migration ${currentMigration.id} (${duration})...`\n );\n }\n }\n\n if (status === \"init\") {\n process.stdout.write(`Checking data migrations...`);\n }\n\n if ([\"done\", \"error\"].includes(status)) {\n this.clearLine();\n process.stdout.write(`Migration run finished, waiting for latest logs...`);\n\n // We want to give AWS some time for the latest log events to become available.\n await new Promise(resolve => {\n setTimeout(resolve, 8000);\n });\n\n if (currentLogStreamName) {\n this.clearLine();\n await this.logReporter.printLogs(currentLogStreamName);\n process.stdout.write(`\\n---------- MIGRATION LOGS END ----------\\n`);\n }\n }\n\n this.firstCall = false;\n }\n\n private clearLine() {\n readline.clearLine(process.stdout, 0);\n readline.cursorTo(process.stdout, 0);\n }\n\n private getDuration(since: string) {\n const ms = new Date().getTime() - new Date(since).getTime();\n let seconds = Math.floor(ms / 1000);\n let minutes = undefined;\n if (seconds > 60) {\n minutes = Math.floor(seconds / 60);\n seconds = Math.floor(seconds % 60);\n }\n\n return minutes ? `${minutes}m ${seconds}s` : `${seconds}s`;\n }\n}\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,UAAU;AAK/B,OAAO,MAAMC,4BAA4B,CAAoC;EAEjEC,SAAS,GAAG,IAAI;EAExBC,WAAWA,CAACC,WAAwB,EAAE;IAClC,IAAI,CAACA,WAAW,GAAGA,WAAW;IAC9BC,OAAO,CAACC,GAAG,CAAC,uCAAuC,CAAC;EACxD;EAEA,MAAMC,MAAMA,CAACC,eAAgC,EAAE;IAC3C,MAAM;MAAEC,MAAM;MAAEC,UAAU;MAAEC;IAAQ,CAAC,GAAGH,eAAe;IACvD,IAAI,CAACI,SAAS,CAAC,CAAC;IAEhB,MAAMC,oBAAoB,GAAGF,OAAO,EAAEG,aAAa;IACnD,IAAID,oBAAoB,EAAE;MACtB,IAAI,CAACT,WAAW,CAACW,gBAA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AS,GAAG,KAAK;EAC1B;EAEQU,SAASA,CAAA,EAAG;IAChBZ,QAAQ,CAACY,SAAS,CAACK,OAAO,CAACC,MAAM,EAAE,CAAC,CAAC;IACrClB,QAAQ,CAACiC,QAAQ,CAAChB,OAAO,CAACC,MAAM,EAAE,CAAC,CAAC;EACxC;EAEQO,WAAWA,CAACS,KAAa,EAAE;IAC/B,MAAMC,EAAE,GAAG,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,GAAG,IAAID,IAAI,CAACF,KAAK,CAAC,CAACG,OAAO,CAAC,CAAC;IAC3D,IAAIC,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACL,EAAE,GAAG,IAAI,CAAC;IACnC,IAAIM,OAAO,GAAGC,SAAS;IACvB,IAAIJ,OAAO,GAAG,EAAE,EAAE;MACdG,OAAO,GAAGF,IAAI,CAACC,KAAK,CAACF,OAAO,GAAG,EAAE,CAAC;MAClCA,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACF,OAAO,GAAG,EAAE,CAAC;IACtC;IAEA,OAAOG,OAAO,GAAG,GAAGA,OAAO,KAAKH,OAAO,GAAG,GAAG,GAAGA,OAAO,GAAG;EAC9D;AACJ","ignoreList":[]}
|
package/cli/LogReporter.d.ts
CHANGED
package/cli/LogReporter.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.LogReporter = void 0;
|
|
7
|
-
var _LogStream = require("./LogStream");
|
|
8
|
-
class LogReporter {
|
|
1
|
+
import { LogStream } from "./LogStream.js";
|
|
2
|
+
export class LogReporter {
|
|
9
3
|
logStreams = new Set();
|
|
10
4
|
constructor(functionName) {
|
|
11
5
|
const baseName = functionName.split(":").pop();
|
|
@@ -33,11 +27,10 @@ class LogReporter {
|
|
|
33
27
|
process.stdout.write("\n");
|
|
34
28
|
}
|
|
35
29
|
initializeStream(name) {
|
|
36
|
-
const logStream =
|
|
30
|
+
const logStream = LogStream.create(this.logGroupName, name);
|
|
37
31
|
this.logStreams.add(logStream);
|
|
38
32
|
return logStream;
|
|
39
33
|
}
|
|
40
34
|
}
|
|
41
|
-
exports.LogReporter = LogReporter;
|
|
42
35
|
|
|
43
36
|
//# sourceMappingURL=LogReporter.js.map
|
package/cli/LogReporter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["LogStream","LogReporter","logStreams","Set","constructor","functionName","baseName","split","pop","logGroupName","logsCreatedSince","Date","now","printLogs","logStreamName","logStream","initializeStream","printLogsSince","printLogStreamLinks","size","Array","from","process","stdout","write","getLogStreamLink","name","create","add"],"sources":["LogReporter.ts"],"sourcesContent":["import { LogStream } from \"./LogStream.js\";\n\nexport class LogReporter {\n private readonly logGroupName: string;\n private readonly logsCreatedSince: number;\n private readonly logStreams = new Set<LogStream>();\n\n constructor(functionName: string) {\n const baseName = functionName.split(\":\").pop();\n this.logGroupName = `/aws/lambda/${baseName}`;\n this.logsCreatedSince = Date.now();\n }\n\n public async printLogs(logStreamName: string) {\n const logStream = this.initializeStream(logStreamName);\n await logStream.printLogsSince(this.logsCreatedSince);\n }\n\n public printLogStreamLinks() {\n if (this.logStreams.size === 0) {\n return;\n }\n\n const logStreams = Array.from(this.logStreams);\n\n if (this.logStreams.size === 1) {\n process.stdout.write(\n `\\nTo view detailed logs, visit the following AWS CloudWatch log stream:\\n`\n );\n process.stdout.write(logStreams[0].getLogStreamLink());\n } else {\n process.stdout.write(\n `\\nTo view detailed logs, visit the following AWS CloudWatch log streams:\\n`\n );\n\n for (const logStream of logStreams) {\n process.stdout.write(`- ${logStream.getLogStreamLink()}`);\n }\n }\n\n process.stdout.write(\"\\n\");\n }\n\n public initializeStream(name: string) {\n const logStream = LogStream.create(this.logGroupName, name);\n this.logStreams.add(logStream);\n return logStream;\n }\n}\n"],"mappings":"AAA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