sonamu 0.4.1 → 0.4.3
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/bin/cli.js +51 -51
- package/dist/bin/cli.js.map +1 -1
- package/dist/bin/cli.mjs +2 -2
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/{chunk-FLPD24HS.mjs → chunk-4K2F3SOM.mjs} +2 -2
- package/dist/{chunk-I2MMJRJN.mjs → chunk-HIUT56RE.mjs} +32 -15
- package/dist/chunk-HIUT56RE.mjs.map +1 -0
- package/dist/{chunk-QK5XXJUX.mjs → chunk-HVVCQLAU.mjs} +2 -2
- package/dist/{chunk-Z2P7XTXE.js → chunk-JBKIW5LD.js} +130 -113
- package/dist/chunk-JBKIW5LD.js.map +1 -0
- package/dist/{chunk-U636LQJJ.js → chunk-N6N3LENC.js} +4 -4
- package/dist/{chunk-W7KDVJLQ.js → chunk-UAG3SKFM.js} +7 -7
- package/dist/{chunk-XT6LHCX5.js → chunk-WJGRXAXE.js} +12 -4
- package/dist/chunk-WJGRXAXE.js.map +1 -0
- package/dist/{chunk-PP2PSSAG.mjs → chunk-ZFLQLW37.mjs} +12 -4
- package/dist/{chunk-PP2PSSAG.mjs.map → chunk-ZFLQLW37.mjs.map} +1 -1
- package/dist/database/drivers/knex/base-model.js +8 -8
- package/dist/database/drivers/knex/base-model.mjs +3 -3
- package/dist/database/drivers/kysely/base-model.js +9 -9
- package/dist/database/drivers/kysely/base-model.mjs +3 -3
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +7 -7
- package/dist/index.mjs +3 -3
- package/package.json +2 -2
- package/src/api/sonamu.ts +17 -4
- package/src/bin/cli.ts +1 -0
- package/src/entity/migrator.ts +51 -19
- package/dist/chunk-I2MMJRJN.mjs.map +0 -1
- package/dist/chunk-XT6LHCX5.js.map +0 -1
- package/dist/chunk-Z2P7XTXE.js.map +0 -1
- /package/dist/{chunk-FLPD24HS.mjs.map → chunk-4K2F3SOM.mjs.map} +0 -0
- /package/dist/{chunk-QK5XXJUX.mjs.map → chunk-HVVCQLAU.mjs.map} +0 -0
- /package/dist/{chunk-U636LQJJ.js.map → chunk-N6N3LENC.js.map} +0 -0
- /package/dist/{chunk-W7KDVJLQ.js.map → chunk-UAG3SKFM.js.map} +0 -0
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunkWJGRXAXEjs = require('./chunk-WJGRXAXE.js');
|
|
20
20
|
|
|
21
21
|
// src/entity/migrator.ts
|
|
22
22
|
var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
|
|
@@ -34,10 +34,10 @@ var Migrator = class {
|
|
|
34
34
|
constructor(options) {
|
|
35
35
|
this.mode = options.mode;
|
|
36
36
|
if (this.mode === "dev") {
|
|
37
|
-
const devDB =
|
|
38
|
-
const testDB =
|
|
39
|
-
const fixtureLocalDB =
|
|
40
|
-
const uniqConfigs =
|
|
37
|
+
const devDB = _chunkWJGRXAXEjs.DB.getClient("development_master");
|
|
38
|
+
const testDB = _chunkWJGRXAXEjs.DB.getClient("test");
|
|
39
|
+
const fixtureLocalDB = _chunkWJGRXAXEjs.DB.getClient("fixture_local");
|
|
40
|
+
const uniqConfigs = _chunkWJGRXAXEjs.DB.getUniqueConfigs([
|
|
41
41
|
"development_master",
|
|
42
42
|
"test",
|
|
43
43
|
"fixture_local",
|
|
@@ -45,7 +45,7 @@ var Migrator = class {
|
|
|
45
45
|
]);
|
|
46
46
|
const applyDBs = [devDB, testDB, fixtureLocalDB];
|
|
47
47
|
if (uniqConfigs.length === 4) {
|
|
48
|
-
const fixtureRemoteDB =
|
|
48
|
+
const fixtureRemoteDB = _chunkWJGRXAXEjs.DB.getClient("fixture_remote");
|
|
49
49
|
applyDBs.push(fixtureRemoteDB);
|
|
50
50
|
}
|
|
51
51
|
this.targets = {
|
|
@@ -55,8 +55,8 @@ var Migrator = class {
|
|
|
55
55
|
apply: applyDBs
|
|
56
56
|
};
|
|
57
57
|
} else if (this.mode === "deploy") {
|
|
58
|
-
const productionDB =
|
|
59
|
-
const testDB =
|
|
58
|
+
const productionDB = _chunkWJGRXAXEjs.DB.getClient("production_master");
|
|
59
|
+
const testDB = _chunkWJGRXAXEjs.DB.getClient("test");
|
|
60
60
|
this.targets = {
|
|
61
61
|
pending: productionDB,
|
|
62
62
|
shadow: testDB,
|
|
@@ -67,8 +67,8 @@ var Migrator = class {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
async getMigrationCodes() {
|
|
70
|
-
const srcMigrationsDir = `${
|
|
71
|
-
const distMigrationsDir = `${
|
|
70
|
+
const srcMigrationsDir = `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/src/migrations`;
|
|
71
|
+
const distMigrationsDir = `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/dist/migrations`;
|
|
72
72
|
if (_fsextra2.default.existsSync(srcMigrationsDir) === false) {
|
|
73
73
|
_fsextra2.default.mkdirSync(srcMigrationsDir, {
|
|
74
74
|
recursive: true
|
|
@@ -113,8 +113,8 @@ var Migrator = class {
|
|
|
113
113
|
const { normal, onlyTs, onlyJs } = await this.getMigrationCodes();
|
|
114
114
|
if (onlyTs.length > 0) {
|
|
115
115
|
console.debug({ onlyTs });
|
|
116
|
-
throw new (0,
|
|
117
|
-
`There
|
|
116
|
+
throw new (0, _chunkWJGRXAXEjs.ServiceUnavailableException)(
|
|
117
|
+
`There are un-compiled TS migration files.
|
|
118
118
|
Please compile them first.
|
|
119
119
|
|
|
120
120
|
${onlyTs.map((f) => f.name).join("\n")}`
|
|
@@ -130,12 +130,12 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
130
130
|
})
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
|
-
const connKeys = Object.keys(
|
|
133
|
+
const connKeys = Object.keys(_chunkWJGRXAXEjs.DB.fullConfig).filter(
|
|
134
134
|
(key) => key.endsWith("_slave") === false
|
|
135
135
|
);
|
|
136
136
|
const statuses = await Promise.all(
|
|
137
137
|
connKeys.map(async (connKey) => {
|
|
138
|
-
const tConn =
|
|
138
|
+
const tConn = _chunkWJGRXAXEjs.DB.getClient(connKey);
|
|
139
139
|
const status = await (async () => {
|
|
140
140
|
try {
|
|
141
141
|
return await tConn.status();
|
|
@@ -172,7 +172,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
172
172
|
if (status0conn === void 0) {
|
|
173
173
|
return [];
|
|
174
174
|
}
|
|
175
|
-
const compareDBconn =
|
|
175
|
+
const compareDBconn = _chunkWJGRXAXEjs.DB.getClient(status0conn.connKey);
|
|
176
176
|
const genCodes = await this.compareMigrations(compareDBconn);
|
|
177
177
|
await compareDBconn.destroy();
|
|
178
178
|
return genCodes;
|
|
@@ -184,11 +184,11 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
186
|
async runAction(action, targets) {
|
|
187
|
-
const configs =
|
|
187
|
+
const configs = _chunkWJGRXAXEjs.DB.getUniqueConfigs(targets);
|
|
188
188
|
const conns = await Promise.all(
|
|
189
189
|
configs.map(async (config) => ({
|
|
190
190
|
connKey: config.connKey,
|
|
191
|
-
db:
|
|
191
|
+
db: _chunkWJGRXAXEjs.DB.getClient(config.connKey)
|
|
192
192
|
}))
|
|
193
193
|
);
|
|
194
194
|
const result = await (async () => {
|
|
@@ -236,8 +236,8 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
236
236
|
);
|
|
237
237
|
}
|
|
238
238
|
const delFiles = codeNames.map((codeName) => [
|
|
239
|
-
`${
|
|
240
|
-
`${
|
|
239
|
+
`${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/src/migrations/${codeName}.ts`,
|
|
240
|
+
`${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/dist/migrations/${codeName}.js`
|
|
241
241
|
]).flat();
|
|
242
242
|
const res = await Promise.all(
|
|
243
243
|
delFiles.map((delFile) => {
|
|
@@ -257,7 +257,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
257
257
|
console.log(_chalk2.default.green("\n\uD604\uC7AC \uBAA8\uB450 \uC2F1\uD06C\uB41C \uC0C1\uD0DC\uC785\uB2C8\uB2E4."));
|
|
258
258
|
return 0;
|
|
259
259
|
}
|
|
260
|
-
const migrationsDir = `${
|
|
260
|
+
const migrationsDir = `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/src/migrations`;
|
|
261
261
|
preparedCodes.filter((pcode) => pcode.formatted).map((pcode, index) => {
|
|
262
262
|
const dateTag = _luxon.DateTime.local().plus({ seconds: index }).toFormat("yyyyMMddHHmmss");
|
|
263
263
|
const filePath = `${migrationsDir}/${dateTag}_${pcode.title}.ts`;
|
|
@@ -268,7 +268,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
268
268
|
}
|
|
269
269
|
async clearPendingList() {
|
|
270
270
|
const pendingList = await this.targets.pending.getMigrations();
|
|
271
|
-
const migrationsDir = `${
|
|
271
|
+
const migrationsDir = `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/src/migrations`;
|
|
272
272
|
const delList = pendingList.map((df) => {
|
|
273
273
|
return _path2.default.join(migrationsDir, `${df}.ts`);
|
|
274
274
|
});
|
|
@@ -332,7 +332,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
332
332
|
if (answer.value === false) {
|
|
333
333
|
return;
|
|
334
334
|
}
|
|
335
|
-
const migrationsDir = `${
|
|
335
|
+
const migrationsDir = `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/src/migrations`;
|
|
336
336
|
codes.filter((code) => code.formatted).map((code, index) => {
|
|
337
337
|
const dateTag = _luxon.DateTime.local().plus({ seconds: index }).toFormat("yyyyMMddHHmmss");
|
|
338
338
|
const filePath = `${migrationsDir}/${dateTag}_${code.title}.ts`;
|
|
@@ -354,7 +354,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
354
354
|
const files = ["src", "dist"].reduce(
|
|
355
355
|
(r, which) => {
|
|
356
356
|
const migrationPath = _path2.default.join(
|
|
357
|
-
|
|
357
|
+
_chunkWJGRXAXEjs.Sonamu.apiRootPath,
|
|
358
358
|
which,
|
|
359
359
|
"migrations"
|
|
360
360
|
);
|
|
@@ -402,7 +402,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
const filesToRm = diffOnDist.map((filename) => {
|
|
405
|
-
return _path2.default.join(
|
|
405
|
+
return _path2.default.join(_chunkWJGRXAXEjs.Sonamu.apiRootPath, "dist", "migrations", filename);
|
|
406
406
|
});
|
|
407
407
|
filesToRm.map((filePath) => {
|
|
408
408
|
_fsextra2.default.unlinkSync(filePath);
|
|
@@ -411,7 +411,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
413
|
async runShadowTest() {
|
|
414
|
-
const tdb =
|
|
414
|
+
const tdb = _chunkWJGRXAXEjs.DB.getClient("test");
|
|
415
415
|
const tdbConn = tdb.connectionInfo;
|
|
416
416
|
const shadowDatabase = tdbConn.database + "__migration_shadow";
|
|
417
417
|
const tmpSqlPath = `/tmp/${shadowDatabase}.sql`;
|
|
@@ -449,7 +449,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
449
449
|
];
|
|
450
450
|
} catch (e) {
|
|
451
451
|
console.error(e);
|
|
452
|
-
throw new (0,
|
|
452
|
+
throw new (0, _chunkWJGRXAXEjs.ServiceUnavailableException)("Shadow DB \uD14C\uC2A4\uD2B8 \uC9C4\uD589 \uC911 \uC5D0\uB7EC");
|
|
453
453
|
} finally {
|
|
454
454
|
await tdb.destroy();
|
|
455
455
|
}
|
|
@@ -472,32 +472,41 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
472
472
|
);
|
|
473
473
|
console.log({ rollbackAllResult });
|
|
474
474
|
console.timeEnd(_chalk2.default.red("rollback-all:"));
|
|
475
|
-
const migrationsDir = `${
|
|
475
|
+
const migrationsDir = `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/src/migrations`;
|
|
476
476
|
console.time(_chalk2.default.red("delete migration files"));
|
|
477
477
|
_child_process.execSync.call(void 0, `rm -f ${migrationsDir}/*`);
|
|
478
478
|
_child_process.execSync.call(void 0, `rm -f ${migrationsDir.replace("/src/", "/dist/")}/*`);
|
|
479
479
|
console.timeEnd(_chalk2.default.red("delete migration files"));
|
|
480
480
|
}
|
|
481
481
|
async compareMigrations(compareDB) {
|
|
482
|
-
const entityIds =
|
|
482
|
+
const entityIds = _chunkWJGRXAXEjs.EntityManager.getAllIds();
|
|
483
483
|
const entitySetsWithJoinTable = entityIds.filter((entityId) => {
|
|
484
|
-
const entity =
|
|
484
|
+
const entity = _chunkWJGRXAXEjs.EntityManager.get(entityId);
|
|
485
485
|
return entity.props.length > 0;
|
|
486
486
|
}).map((entityId) => {
|
|
487
|
-
const entity =
|
|
488
|
-
return this.
|
|
487
|
+
const entity = _chunkWJGRXAXEjs.EntityManager.get(entityId);
|
|
488
|
+
return this.getMigrationSetFromEntity(entity);
|
|
489
489
|
});
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
(
|
|
493
|
-
|
|
490
|
+
const joinTablesWithDup = entitySetsWithJoinTable.map((entitySet) => entitySet.joinTables).flat();
|
|
491
|
+
const joinTables = Object.values(
|
|
492
|
+
_lodash2.default.groupBy(joinTablesWithDup, (jt) => jt.table)
|
|
493
|
+
).map((tables) => {
|
|
494
|
+
if (tables.length === 1) {
|
|
495
|
+
return tables[0];
|
|
494
496
|
}
|
|
495
|
-
|
|
497
|
+
return {
|
|
498
|
+
...tables[0],
|
|
499
|
+
indexes: _lodash2.default.uniqBy(
|
|
500
|
+
tables.flatMap((t) => t.indexes),
|
|
501
|
+
(index) => [index.type, ...index.columns.sort()].join("-")
|
|
502
|
+
)
|
|
503
|
+
};
|
|
504
|
+
});
|
|
496
505
|
const entitySets = [
|
|
497
506
|
...entitySetsWithJoinTable,
|
|
498
507
|
...joinTables
|
|
499
508
|
];
|
|
500
|
-
|
|
509
|
+
const codes = (await Promise.all(
|
|
501
510
|
entitySets.map(async (entitySet) => {
|
|
502
511
|
const dbSet = await this.getMigrationSetFromDB(
|
|
503
512
|
compareDB,
|
|
@@ -505,12 +514,12 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
505
514
|
);
|
|
506
515
|
if (dbSet === null) {
|
|
507
516
|
return [
|
|
508
|
-
await
|
|
517
|
+
await _chunkWJGRXAXEjs.DB.generator.generateCreateCode_ColumnAndIndexes(
|
|
509
518
|
entitySet.table,
|
|
510
519
|
entitySet.columns,
|
|
511
520
|
entitySet.indexes
|
|
512
521
|
),
|
|
513
|
-
...await
|
|
522
|
+
...await _chunkWJGRXAXEjs.DB.generator.generateCreateCode_Foreign(
|
|
514
523
|
entitySet.table,
|
|
515
524
|
entitySet.foreigns
|
|
516
525
|
)
|
|
@@ -556,7 +565,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
556
565
|
if (isEqualColumns && isEqualIndexes) {
|
|
557
566
|
return null;
|
|
558
567
|
} else {
|
|
559
|
-
return
|
|
568
|
+
return _chunkWJGRXAXEjs.DB.generator.generateAlterCode_ColumnAndIndexes(
|
|
560
569
|
entitySet.table,
|
|
561
570
|
entityColumns,
|
|
562
571
|
entityIndexes,
|
|
@@ -582,7 +591,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
582
591
|
(a) => [a.to, ...a.columns].join("-")
|
|
583
592
|
).map((f) => replaceNoActionOnMySQL(f));
|
|
584
593
|
if (_fastdeepequal2.default.call(void 0, entityForeigns, dbForeigns) === false) {
|
|
585
|
-
return
|
|
594
|
+
return _chunkWJGRXAXEjs.DB.generator.generateAlterCode_Foreigns(
|
|
586
595
|
entitySet.table,
|
|
587
596
|
entityForeigns,
|
|
588
597
|
dbForeigns
|
|
@@ -621,7 +630,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
621
630
|
table
|
|
622
631
|
);
|
|
623
632
|
} catch (e) {
|
|
624
|
-
if (
|
|
633
|
+
if (_chunkWJGRXAXEjs.isKnexError.call(void 0, e) && e.code === "ER_NO_SUCH_TABLE") {
|
|
625
634
|
return null;
|
|
626
635
|
}
|
|
627
636
|
console.error(e);
|
|
@@ -793,22 +802,22 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
793
802
|
}
|
|
794
803
|
}
|
|
795
804
|
/*
|
|
796
|
-
|
|
805
|
+
Entity 내용 읽어서 MigrationSetAndJoinTable 추출
|
|
797
806
|
*/
|
|
798
|
-
|
|
807
|
+
getMigrationSetFromEntity(entity) {
|
|
799
808
|
const migrationSet = entity.props.reduce(
|
|
800
809
|
(r, prop) => {
|
|
801
|
-
if (
|
|
810
|
+
if (_chunkWJGRXAXEjs.isVirtualProp.call(void 0, prop)) {
|
|
802
811
|
return r;
|
|
803
812
|
}
|
|
804
|
-
if (
|
|
813
|
+
if (_chunkWJGRXAXEjs.isHasManyRelationProp.call(void 0, prop)) {
|
|
805
814
|
return r;
|
|
806
815
|
}
|
|
807
|
-
if (!
|
|
816
|
+
if (!_chunkWJGRXAXEjs.isRelationProp.call(void 0, prop)) {
|
|
808
817
|
let type;
|
|
809
|
-
if (
|
|
818
|
+
if (_chunkWJGRXAXEjs.isTextProp.call(void 0, prop)) {
|
|
810
819
|
type = prop.textType;
|
|
811
|
-
} else if (
|
|
820
|
+
} else if (_chunkWJGRXAXEjs.isEnumProp.call(void 0, prop)) {
|
|
812
821
|
type = "string";
|
|
813
822
|
} else {
|
|
814
823
|
type = prop.type;
|
|
@@ -816,8 +825,8 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
816
825
|
const column = {
|
|
817
826
|
name: prop.name,
|
|
818
827
|
type,
|
|
819
|
-
...
|
|
820
|
-
...(
|
|
828
|
+
..._chunkWJGRXAXEjs.isIntegerProp.call(void 0, prop) && { unsigned: prop.unsigned === true },
|
|
829
|
+
...(_chunkWJGRXAXEjs.isStringProp.call(void 0, prop) || _chunkWJGRXAXEjs.isEnumProp.call(void 0, prop)) && {
|
|
821
830
|
length: prop.length
|
|
822
831
|
},
|
|
823
832
|
nullable: prop.nullable === true,
|
|
@@ -831,15 +840,15 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
831
840
|
})(),
|
|
832
841
|
// FIXME: float(N, M) deprecated
|
|
833
842
|
// Decimal, Float 타입의 경우 precision, scale 추가
|
|
834
|
-
...(
|
|
843
|
+
...(_chunkWJGRXAXEjs.isDecimalProp.call(void 0, prop) || _chunkWJGRXAXEjs.isFloatProp.call(void 0, prop)) && {
|
|
835
844
|
precision: _nullishCoalesce(prop.precision, () => ( 8)),
|
|
836
845
|
scale: _nullishCoalesce(prop.scale, () => ( 2))
|
|
837
846
|
}
|
|
838
847
|
};
|
|
839
848
|
r.columns.push(column);
|
|
840
849
|
}
|
|
841
|
-
if (
|
|
842
|
-
const relMd =
|
|
850
|
+
if (_chunkWJGRXAXEjs.isManyToManyRelationProp.call(void 0, prop)) {
|
|
851
|
+
const relMd = _chunkWJGRXAXEjs.EntityManager.get(prop.with);
|
|
843
852
|
const [table1, table2] = prop.joinTable.split("__");
|
|
844
853
|
const join = {
|
|
845
854
|
from: `${entity.table}.id`,
|
|
@@ -894,16 +903,24 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
894
903
|
}
|
|
895
904
|
],
|
|
896
905
|
foreigns: fields.map((field) => {
|
|
906
|
+
const col = field.split(".")[1];
|
|
907
|
+
const to = (() => {
|
|
908
|
+
if (_inflection2.default.singularize(join.to.split(".")[0]) + "_id" === col) {
|
|
909
|
+
return join.to;
|
|
910
|
+
} else {
|
|
911
|
+
return join.from;
|
|
912
|
+
}
|
|
913
|
+
})();
|
|
897
914
|
return {
|
|
898
|
-
columns: [
|
|
899
|
-
to
|
|
915
|
+
columns: [col],
|
|
916
|
+
to,
|
|
900
917
|
onUpdate: through.onUpdate,
|
|
901
918
|
onDelete: through.onDelete
|
|
902
919
|
};
|
|
903
920
|
})
|
|
904
921
|
});
|
|
905
922
|
return r;
|
|
906
|
-
} else if (
|
|
923
|
+
} else if (_chunkWJGRXAXEjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) {
|
|
907
924
|
const idColumnName = prop.name + "_id";
|
|
908
925
|
r.columns.push({
|
|
909
926
|
name: idColumnName,
|
|
@@ -947,7 +964,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
|
|
|
947
964
|
*/
|
|
948
965
|
showMigrationSet(which, migrationSet) {
|
|
949
966
|
const { columns, indexes, foreigns } = migrationSet;
|
|
950
|
-
const styledChalk = which === "
|
|
967
|
+
const styledChalk = which === "Entity" ? _chalk2.default.bgGreen.black : _chalk2.default.bgBlue.black;
|
|
951
968
|
console.log(
|
|
952
969
|
styledChalk(
|
|
953
970
|
`${which} ${migrationSet.table} Columns `
|
|
@@ -1039,13 +1056,13 @@ var RelationGraph = (_class = class {constructor() { _class.prototype.__init.cal
|
|
|
1039
1056
|
const node = this.graph.get(fixture.fixtureId);
|
|
1040
1057
|
for (const [, column] of Object.entries(fixture.columns)) {
|
|
1041
1058
|
const prop = column.prop;
|
|
1042
|
-
if (
|
|
1043
|
-
if (
|
|
1059
|
+
if (_chunkWJGRXAXEjs.isRelationProp.call(void 0, prop)) {
|
|
1060
|
+
if (_chunkWJGRXAXEjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) {
|
|
1044
1061
|
const relatedFixtureId = `${prop.with}#${column.value}`;
|
|
1045
1062
|
if (this.graph.has(relatedFixtureId)) {
|
|
1046
1063
|
node.related.add(relatedFixtureId);
|
|
1047
1064
|
}
|
|
1048
|
-
} else if (
|
|
1065
|
+
} else if (_chunkWJGRXAXEjs.isManyToManyRelationProp.call(void 0, prop)) {
|
|
1049
1066
|
const relatedIds = column.value;
|
|
1050
1067
|
for (const relatedId of relatedIds) {
|
|
1051
1068
|
const relatedFixtureId = `${prop.with}#${relatedId}`;
|
|
@@ -1071,11 +1088,11 @@ var RelationGraph = (_class = class {constructor() { _class.prototype.__init.cal
|
|
|
1071
1088
|
}
|
|
1072
1089
|
tempVisited.add(fixtureId);
|
|
1073
1090
|
const node = this.graph.get(fixtureId);
|
|
1074
|
-
const entity =
|
|
1091
|
+
const entity = _chunkWJGRXAXEjs.EntityManager.get(node.entityId);
|
|
1075
1092
|
for (const depId of node.related) {
|
|
1076
1093
|
const depNode = this.graph.get(depId);
|
|
1077
1094
|
const relationProp = entity.props.find(
|
|
1078
|
-
(prop) =>
|
|
1095
|
+
(prop) => _chunkWJGRXAXEjs.isRelationProp.call(void 0, prop) && (_chunkWJGRXAXEjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) && prop.with === depNode.entityId
|
|
1079
1096
|
);
|
|
1080
1097
|
if (relationProp && !relationProp.nullable) {
|
|
1081
1098
|
visit(depId);
|
|
@@ -1101,39 +1118,39 @@ var RelationGraph = (_class = class {constructor() { _class.prototype.__init.cal
|
|
|
1101
1118
|
var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__init2.call(this); }
|
|
1102
1119
|
__init2() {this.relationGraph = new RelationGraph()}
|
|
1103
1120
|
init() {
|
|
1104
|
-
|
|
1121
|
+
_chunkWJGRXAXEjs.DB.testInit();
|
|
1105
1122
|
}
|
|
1106
1123
|
async cleanAndSeed(usingTables) {
|
|
1107
1124
|
const tableNames = await (async () => {
|
|
1108
1125
|
if (usingTables) {
|
|
1109
1126
|
return usingTables;
|
|
1110
1127
|
}
|
|
1111
|
-
const tables = await
|
|
1128
|
+
const tables = await _chunkWJGRXAXEjs.DB.tdb.raw(
|
|
1112
1129
|
`SHOW TABLE STATUS WHERE Engine IS NOT NULL`
|
|
1113
1130
|
);
|
|
1114
1131
|
return tables.map((tableInfo) => tableInfo["Name"]);
|
|
1115
1132
|
})();
|
|
1116
|
-
await
|
|
1133
|
+
await _chunkWJGRXAXEjs.DB.tdb.raw(`SET FOREIGN_KEY_CHECKS = 0`);
|
|
1117
1134
|
for await (let tableName of tableNames) {
|
|
1118
1135
|
if (tableName == "migrations") {
|
|
1119
1136
|
continue;
|
|
1120
1137
|
}
|
|
1121
|
-
const [fdbChecksumRow] = await
|
|
1138
|
+
const [fdbChecksumRow] = await _chunkWJGRXAXEjs.DB.fdb.raw(
|
|
1122
1139
|
`CHECKSUM TABLE ${tableName}`
|
|
1123
1140
|
);
|
|
1124
1141
|
const fdbChecksum = fdbChecksumRow["Checksum"];
|
|
1125
|
-
const [tdbChecksumRow] = await
|
|
1142
|
+
const [tdbChecksumRow] = await _chunkWJGRXAXEjs.DB.tdb.raw(
|
|
1126
1143
|
`CHECKSUM TABLE ${tableName}`
|
|
1127
1144
|
);
|
|
1128
1145
|
const tdbChecksum = tdbChecksumRow["Checksum"];
|
|
1129
1146
|
if (fdbChecksum !== tdbChecksum) {
|
|
1130
|
-
await
|
|
1131
|
-
const rawQuery = `INSERT INTO ${
|
|
1132
|
-
SELECT * FROM ${
|
|
1133
|
-
await
|
|
1147
|
+
await _chunkWJGRXAXEjs.DB.tdb.truncate(tableName);
|
|
1148
|
+
const rawQuery = `INSERT INTO ${_chunkWJGRXAXEjs.DB.connectionInfo.test.database}.${tableName}
|
|
1149
|
+
SELECT * FROM ${_chunkWJGRXAXEjs.DB.connectionInfo.fixture_local.database}.${tableName}`;
|
|
1150
|
+
await _chunkWJGRXAXEjs.DB.tdb.raw(rawQuery);
|
|
1134
1151
|
}
|
|
1135
1152
|
}
|
|
1136
|
-
await
|
|
1153
|
+
await _chunkWJGRXAXEjs.DB.tdb.raw(`SET FOREIGN_KEY_CHECKS = 1`);
|
|
1137
1154
|
}
|
|
1138
1155
|
async getChecksum(db, tableName) {
|
|
1139
1156
|
const [checksumRow] = await db.raw(
|
|
@@ -1142,8 +1159,8 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1142
1159
|
return checksumRow.Checksum;
|
|
1143
1160
|
}
|
|
1144
1161
|
async sync() {
|
|
1145
|
-
const frdb =
|
|
1146
|
-
const tables = await
|
|
1162
|
+
const frdb = _chunkWJGRXAXEjs.DB.getClient("fixture_remote");
|
|
1163
|
+
const tables = await _chunkWJGRXAXEjs.DB.fdb.raw(
|
|
1147
1164
|
"SHOW TABLE STATUS WHERE Engine IS NOT NULL"
|
|
1148
1165
|
);
|
|
1149
1166
|
const tableNames = tables.map(
|
|
@@ -1152,13 +1169,13 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1152
1169
|
console.log(_chalk2.default.magenta("SYNC..."));
|
|
1153
1170
|
await Promise.all(
|
|
1154
1171
|
tableNames.map(async (tableName) => {
|
|
1155
|
-
if (tableName.startsWith(
|
|
1172
|
+
if (tableName.startsWith(_chunkWJGRXAXEjs.DB.migrationTable)) {
|
|
1156
1173
|
return;
|
|
1157
1174
|
}
|
|
1158
1175
|
const remoteChecksum = await this.getChecksum(frdb, tableName);
|
|
1159
|
-
const localChecksum = await this.getChecksum(
|
|
1176
|
+
const localChecksum = await this.getChecksum(_chunkWJGRXAXEjs.DB.fdb, tableName);
|
|
1160
1177
|
if (remoteChecksum !== localChecksum) {
|
|
1161
|
-
await
|
|
1178
|
+
await _chunkWJGRXAXEjs.DB.fdb.trx(async (transaction) => {
|
|
1162
1179
|
await transaction.raw(`SET FOREIGN_KEY_CHECKS = 0`);
|
|
1163
1180
|
await transaction.truncate(tableName);
|
|
1164
1181
|
const rows = await frdb.raw(`SELECT * FROM ${tableName}`);
|
|
@@ -1189,7 +1206,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1189
1206
|
})
|
|
1190
1207
|
)).flat()
|
|
1191
1208
|
);
|
|
1192
|
-
const wdb =
|
|
1209
|
+
const wdb = _chunkWJGRXAXEjs.DB.toClient(_chunkWJGRXAXEjs.DB.getDB("w"));
|
|
1193
1210
|
for (let query of queries) {
|
|
1194
1211
|
const [rsh] = await wdb.raw(query);
|
|
1195
1212
|
console.log({
|
|
@@ -1200,23 +1217,23 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1200
1217
|
}
|
|
1201
1218
|
async getImportQueries(entityId, field, id) {
|
|
1202
1219
|
console.log({ entityId, field, id });
|
|
1203
|
-
const entity =
|
|
1204
|
-
const wdb =
|
|
1220
|
+
const entity = _chunkWJGRXAXEjs.EntityManager.get(entityId);
|
|
1221
|
+
const wdb = _chunkWJGRXAXEjs.DB.toClient(_chunkWJGRXAXEjs.DB.getDB("w"));
|
|
1205
1222
|
const [row] = await wdb.raw(
|
|
1206
1223
|
`SELECT * FROM ${entity.table} WHERE ${field} = ${id} LIMIT 1`
|
|
1207
1224
|
);
|
|
1208
1225
|
if (row === void 0) {
|
|
1209
1226
|
throw new Error(`${entityId}#${id} row\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.`);
|
|
1210
1227
|
}
|
|
1211
|
-
const fixtureDatabase =
|
|
1212
|
-
const realDatabase =
|
|
1228
|
+
const fixtureDatabase = _chunkWJGRXAXEjs.DB.connectionInfo.fixture_remote.database;
|
|
1229
|
+
const realDatabase = _chunkWJGRXAXEjs.DB.connectionInfo.production_master.database;
|
|
1213
1230
|
const selfQuery = `INSERT IGNORE INTO \`${fixtureDatabase}\`.\`${entity.table}\` (SELECT * FROM \`${realDatabase}\`.\`${entity.table}\` WHERE \`id\` = ${id})`;
|
|
1214
1231
|
const args = Object.entries(entity.relations).filter(
|
|
1215
|
-
([, relation]) =>
|
|
1232
|
+
([, relation]) => _chunkWJGRXAXEjs.isBelongsToOneRelationProp.call(void 0, relation) || _chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, relation) && relation.customJoinClause === void 0
|
|
1216
1233
|
).map(([, relation]) => {
|
|
1217
1234
|
let field2;
|
|
1218
1235
|
let id2;
|
|
1219
|
-
if (
|
|
1236
|
+
if (_chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, relation) && !relation.hasJoinColumn) {
|
|
1220
1237
|
field2 = `${relation.name}_id`;
|
|
1221
1238
|
id2 = row["id"];
|
|
1222
1239
|
} else {
|
|
@@ -1237,14 +1254,14 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1237
1254
|
return [..._lodash2.default.uniq(relQueries.reverse().flat()), selfQuery];
|
|
1238
1255
|
}
|
|
1239
1256
|
async destory() {
|
|
1240
|
-
await
|
|
1241
|
-
await
|
|
1257
|
+
await _chunkWJGRXAXEjs.DB.testDestroy();
|
|
1258
|
+
await _chunkWJGRXAXEjs.DB.destroy();
|
|
1242
1259
|
}
|
|
1243
1260
|
async getFixtures(sourceDBName, targetDBName, searchOptions) {
|
|
1244
|
-
const sourceDB =
|
|
1245
|
-
const targetDB =
|
|
1261
|
+
const sourceDB = _chunkWJGRXAXEjs.DB.getClient(sourceDBName);
|
|
1262
|
+
const targetDB = _chunkWJGRXAXEjs.DB.getClient(targetDBName);
|
|
1246
1263
|
const { entityId, field, value, searchType } = searchOptions;
|
|
1247
|
-
const entity =
|
|
1264
|
+
const entity = _chunkWJGRXAXEjs.EntityManager.get(entityId);
|
|
1248
1265
|
const column = _optionalChain([entity, 'access', _10 => _10.props, 'access', _11 => _11.find, 'call', _12 => _12((prop) => prop.name === field), 'optionalAccess', _13 => _13.type]) === "relation" ? `${field}_id` : field;
|
|
1249
1266
|
let query = sourceDB.from(entity.table).selectAll();
|
|
1250
1267
|
if (searchType === "equals") {
|
|
@@ -1269,7 +1286,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1269
1286
|
}
|
|
1270
1287
|
}
|
|
1271
1288
|
for await (const fixture of fixtures) {
|
|
1272
|
-
const entity2 =
|
|
1289
|
+
const entity2 = _chunkWJGRXAXEjs.EntityManager.get(fixture.entityId);
|
|
1273
1290
|
const [row] = await targetDB.from(entity2.table).selectAll().where(["id", "=", fixture.id]).first().execute();
|
|
1274
1291
|
if (row) {
|
|
1275
1292
|
const [record] = await this.createFixtureRecord(entity2, row, {
|
|
@@ -1312,43 +1329,43 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1312
1329
|
belongsRecords: []
|
|
1313
1330
|
};
|
|
1314
1331
|
for (const prop of entity2.props) {
|
|
1315
|
-
if (
|
|
1332
|
+
if (_chunkWJGRXAXEjs.isVirtualProp.call(void 0, prop)) {
|
|
1316
1333
|
continue;
|
|
1317
1334
|
}
|
|
1318
1335
|
record.columns[prop.name] = {
|
|
1319
1336
|
prop,
|
|
1320
1337
|
value: row2[prop.name]
|
|
1321
1338
|
};
|
|
1322
|
-
const db = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _14 => _14._db]), () => (
|
|
1323
|
-
if (
|
|
1324
|
-
const relatedEntity =
|
|
1339
|
+
const db = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _14 => _14._db]), () => ( _chunkWJGRXAXEjs.DB.toClient(_chunkWJGRXAXEjs.DB.getDB("w"))));
|
|
1340
|
+
if (_chunkWJGRXAXEjs.isManyToManyRelationProp.call(void 0, prop)) {
|
|
1341
|
+
const relatedEntity = _chunkWJGRXAXEjs.EntityManager.get(prop.with);
|
|
1325
1342
|
const throughTable = prop.joinTable;
|
|
1326
1343
|
const fromColumn = `${_inflection2.default.singularize(entity2.table)}_id`;
|
|
1327
1344
|
const toColumn = `${_inflection2.default.singularize(relatedEntity.table)}_id`;
|
|
1328
1345
|
const _relatedIds = await db.from(throughTable).select(toColumn).where([fromColumn, "=", row2.id]).execute();
|
|
1329
1346
|
const relatedIds = _relatedIds.map((r) => parseInt(r[toColumn]));
|
|
1330
1347
|
record.columns[prop.name].value = relatedIds;
|
|
1331
|
-
} else if (
|
|
1332
|
-
const relatedEntity =
|
|
1348
|
+
} else if (_chunkWJGRXAXEjs.isHasManyRelationProp.call(void 0, prop)) {
|
|
1349
|
+
const relatedEntity = _chunkWJGRXAXEjs.EntityManager.get(prop.with);
|
|
1333
1350
|
const relatedIds = await db.from(relatedEntity.table).select("id").where([prop.joinColumn, "=", row2.id]).pluck("id");
|
|
1334
1351
|
record.columns[prop.name].value = relatedIds;
|
|
1335
|
-
} else if (
|
|
1336
|
-
const relatedEntity =
|
|
1352
|
+
} else if (_chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, prop) && !prop.hasJoinColumn) {
|
|
1353
|
+
const relatedEntity = _chunkWJGRXAXEjs.EntityManager.get(prop.with);
|
|
1337
1354
|
const relatedProp = relatedEntity.props.find(
|
|
1338
|
-
(p) =>
|
|
1355
|
+
(p) => _chunkWJGRXAXEjs.isRelationProp.call(void 0, p) && p.with === entity2.id
|
|
1339
1356
|
);
|
|
1340
1357
|
if (relatedProp) {
|
|
1341
1358
|
const [relatedRow] = await db.from(relatedEntity.table).select("id").where([relatedProp.name, "=", row2.id]).first().execute();
|
|
1342
1359
|
record.columns[prop.name].value = _optionalChain([relatedRow, 'optionalAccess', _15 => _15.id]);
|
|
1343
1360
|
}
|
|
1344
|
-
} else if (
|
|
1361
|
+
} else if (_chunkWJGRXAXEjs.isRelationProp.call(void 0, prop)) {
|
|
1345
1362
|
const relatedId = row2[`${prop.name}_id`];
|
|
1346
1363
|
record.columns[prop.name].value = relatedId;
|
|
1347
1364
|
if (relatedId) {
|
|
1348
1365
|
record.belongsRecords.push(`${prop.with}#${relatedId}`);
|
|
1349
1366
|
}
|
|
1350
1367
|
if (!_optionalChain([options, 'optionalAccess', _16 => _16.singleRecord]) && relatedId) {
|
|
1351
|
-
const relatedEntity =
|
|
1368
|
+
const relatedEntity = _chunkWJGRXAXEjs.EntityManager.get(prop.with);
|
|
1352
1369
|
const [relatedRow] = await db.from(relatedEntity.table).selectAll().where(["id", "=", relatedId]).first().execute();
|
|
1353
1370
|
if (relatedRow) {
|
|
1354
1371
|
await create(relatedEntity, relatedRow);
|
|
@@ -1365,7 +1382,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1365
1382
|
const fixtures = _lodash2.default.uniqBy(_fixtures, (f) => f.fixtureId);
|
|
1366
1383
|
this.relationGraph.buildGraph(fixtures);
|
|
1367
1384
|
const insertionOrder = this.relationGraph.getInsertionOrder();
|
|
1368
|
-
const db =
|
|
1385
|
+
const db = _chunkWJGRXAXEjs.DB.getClient(dbName);
|
|
1369
1386
|
await db.trx(async (trx) => {
|
|
1370
1387
|
await trx.raw(`SET FOREIGN_KEY_CHECKS = 0`);
|
|
1371
1388
|
for (const fixtureId of insertionOrder) {
|
|
@@ -1395,7 +1412,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1395
1412
|
});
|
|
1396
1413
|
const records = [];
|
|
1397
1414
|
for await (const r of fixtures) {
|
|
1398
|
-
const entity =
|
|
1415
|
+
const entity = _chunkWJGRXAXEjs.EntityManager.get(r.entityId);
|
|
1399
1416
|
const [record] = await db.from(entity.table).selectAll().where(["id", "=", r.id]).first().execute();
|
|
1400
1417
|
records.push({
|
|
1401
1418
|
entityId: r.entityId,
|
|
@@ -1407,17 +1424,17 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1407
1424
|
prepareInsertData(fixture) {
|
|
1408
1425
|
const insertData = {};
|
|
1409
1426
|
for (const [propName, column] of Object.entries(fixture.columns)) {
|
|
1410
|
-
if (
|
|
1427
|
+
if (_chunkWJGRXAXEjs.isVirtualProp.call(void 0, column.prop)) {
|
|
1411
1428
|
continue;
|
|
1412
1429
|
}
|
|
1413
1430
|
const prop = column.prop;
|
|
1414
|
-
if (!
|
|
1431
|
+
if (!_chunkWJGRXAXEjs.isRelationProp.call(void 0, prop)) {
|
|
1415
1432
|
if (prop.type === "json") {
|
|
1416
1433
|
insertData[propName] = JSON.stringify(column.value);
|
|
1417
1434
|
} else {
|
|
1418
1435
|
insertData[propName] = column.value;
|
|
1419
1436
|
}
|
|
1420
|
-
} else if (
|
|
1437
|
+
} else if (_chunkWJGRXAXEjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) {
|
|
1421
1438
|
insertData[`${propName}_id`] = column.value;
|
|
1422
1439
|
}
|
|
1423
1440
|
}
|
|
@@ -1425,7 +1442,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1425
1442
|
}
|
|
1426
1443
|
async insertFixture(db, fixture) {
|
|
1427
1444
|
const insertData = this.prepareInsertData(fixture);
|
|
1428
|
-
const entity =
|
|
1445
|
+
const entity = _chunkWJGRXAXEjs.EntityManager.get(fixture.entityId);
|
|
1429
1446
|
try {
|
|
1430
1447
|
const uniqueFound = await this.checkUniqueViolation(db, entity, fixture);
|
|
1431
1448
|
if (uniqueFound) {
|
|
@@ -1454,15 +1471,15 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1454
1471
|
async handleManyToManyRelations(db, fixture, fixtures) {
|
|
1455
1472
|
for (const [, column] of Object.entries(fixture.columns)) {
|
|
1456
1473
|
const prop = column.prop;
|
|
1457
|
-
if (
|
|
1474
|
+
if (_chunkWJGRXAXEjs.isManyToManyRelationProp.call(void 0, prop)) {
|
|
1458
1475
|
const joinTable = prop.joinTable;
|
|
1459
1476
|
const relatedIds = column.value;
|
|
1460
1477
|
for (const relatedId of relatedIds) {
|
|
1461
1478
|
if (!fixtures.find((f) => f.fixtureId === `${prop.with}#${relatedId}`)) {
|
|
1462
1479
|
continue;
|
|
1463
1480
|
}
|
|
1464
|
-
const entity =
|
|
1465
|
-
const relatedEntity =
|
|
1481
|
+
const entity = _chunkWJGRXAXEjs.EntityManager.get(fixture.entityId);
|
|
1482
|
+
const relatedEntity = _chunkWJGRXAXEjs.EntityManager.get(prop.with);
|
|
1466
1483
|
if (!entity || !relatedEntity) {
|
|
1467
1484
|
throw new Error(
|
|
1468
1485
|
`Entity not found: ${fixture.entityId}, ${prop.with}`
|
|
@@ -1495,7 +1512,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
|
|
|
1495
1512
|
}
|
|
1496
1513
|
}
|
|
1497
1514
|
async addFixtureLoader(code) {
|
|
1498
|
-
const path2 =
|
|
1515
|
+
const path2 = _chunkWJGRXAXEjs.Sonamu.apiRootPath + "/src/testing/fixture.ts";
|
|
1499
1516
|
let content = _fs.readFileSync.call(void 0, path2).toString();
|
|
1500
1517
|
const fixtureLoaderStart = content.indexOf("const fixtureLoader = {");
|
|
1501
1518
|
const fixtureLoaderEnd = content.indexOf("};", fixtureLoaderStart);
|
|
@@ -1547,4 +1564,4 @@ var FixtureManager = new FixtureManagerClass();
|
|
|
1547
1564
|
|
|
1548
1565
|
|
|
1549
1566
|
exports.Migrator = Migrator; exports.FixtureManagerClass = FixtureManagerClass; exports.FixtureManager = FixtureManager;
|
|
1550
|
-
//# sourceMappingURL=chunk-
|
|
1567
|
+
//# sourceMappingURL=chunk-JBKIW5LD.js.map
|