@orion-js/migrations 3.6.7 → 3.6.8
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/lib/service/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { ExecutionContext } from '@orion-js/dogs';
|
|
1
2
|
export interface MigrationServiceOptions {
|
|
2
3
|
name: string;
|
|
3
4
|
useMongoTransactions: false;
|
|
4
5
|
}
|
|
5
6
|
export declare function MigrationService(options: MigrationServiceOptions): ClassDecorator;
|
|
6
7
|
export type MigrationExecutable = {
|
|
7
|
-
runMigration(): Promise<void>;
|
|
8
|
+
runMigration(context: ExecutionContext): Promise<void>;
|
|
8
9
|
} & MigrationServiceOptions;
|
|
9
10
|
export declare function getMigrationsFromServices(services: any[]): MigrationExecutable[];
|
package/lib/service/index.js
CHANGED
|
@@ -19,9 +19,9 @@ function getMigrationsFromServices(services) {
|
|
|
19
19
|
const options = service.prototype.options;
|
|
20
20
|
return {
|
|
21
21
|
...options,
|
|
22
|
-
runMigration: async () => {
|
|
22
|
+
runMigration: async (context) => {
|
|
23
23
|
const instance = (0, services_1.getInstance)(service);
|
|
24
|
-
return await instance.runMigration();
|
|
24
|
+
return await instance.runMigration(context);
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
});
|
|
@@ -10,9 +10,11 @@ const _1 = require(".");
|
|
|
10
10
|
describe('Migration as IOC', () => {
|
|
11
11
|
it('should create a migration service', async () => {
|
|
12
12
|
let didRun = false;
|
|
13
|
+
let didExtend = false;
|
|
13
14
|
let MoveUsersMigrationService = class MoveUsersMigrationService {
|
|
14
|
-
async runMigration() {
|
|
15
|
+
async runMigration(context) {
|
|
15
16
|
didRun = true;
|
|
17
|
+
context.extendLockTime(1000);
|
|
16
18
|
}
|
|
17
19
|
};
|
|
18
20
|
MoveUsersMigrationService = __decorate([
|
|
@@ -25,9 +27,14 @@ describe('Migration as IOC', () => {
|
|
|
25
27
|
let lastName = null;
|
|
26
28
|
for (const { runMigration, name } of migrations) {
|
|
27
29
|
lastName = name;
|
|
28
|
-
await runMigration(
|
|
30
|
+
await runMigration({
|
|
31
|
+
extendLockTime: time => {
|
|
32
|
+
didExtend = true;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
29
35
|
}
|
|
30
36
|
expect(lastName).toBe('moveUsers');
|
|
31
37
|
expect(didRun).toBe(true);
|
|
38
|
+
expect(didExtend).toBe(true);
|
|
32
39
|
});
|
|
33
40
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/migrations",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.8",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "90170d94e2b04b940ac2d1272f77e139fa56ecd8"
|
|
44
44
|
}
|