@alpha.consultings/eloquent-orm.js 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/PACKAGE-UPDATE-SUMMARY.md +18 -11
- package/README.md +5 -5
- package/dist/Model.d.ts +1 -1
- package/dist/Model.js +3 -3
- package/dist/cli/commands/cacheClear.js +12 -12
- package/dist/cli/commands/cacheStats.js +12 -12
- package/dist/cli/commands/dbSeed.d.ts +1 -1
- package/dist/cli/commands/dbSeed.js +23 -23
- package/dist/cli/commands/dbSeedBootstrapPrecheck.d.ts +1 -1
- package/dist/cli/commands/dbSeedBootstrapPrecheck.js +2 -2
- package/dist/cli/commands/dbSeedFresh.d.ts +1 -1
- package/dist/cli/commands/dbSeedFresh.js +10 -10
- package/dist/cli/commands/demoScenario.js +11 -11
- package/dist/cli/commands/factoryStatus.js +13 -13
- package/dist/cli/commands/makeController.js +11 -11
- package/dist/cli/commands/makeFactory.js +21 -21
- package/dist/cli/commands/makeMigration.d.ts +1 -1
- package/dist/cli/commands/makeMigration.js +31 -17
- package/dist/cli/commands/makeModel.js +30 -30
- package/dist/cli/commands/makeRegistry.d.ts +5 -8
- package/dist/cli/commands/makeRegistry.js +18 -68
- package/dist/cli/commands/makeScenario.js +49 -43
- package/dist/cli/commands/makeSeed.js +12 -9
- package/dist/cli/commands/makeService.js +10 -10
- package/dist/cli/commands/migrateFresh.d.ts +1 -1
- package/dist/cli/commands/migrateFresh.js +14 -14
- package/dist/cli/commands/migrateReset.d.ts +1 -1
- package/dist/cli/commands/migrateReset.js +4 -4
- package/dist/cli/commands/migrateRollback.d.ts +1 -1
- package/dist/cli/commands/migrateRollback.js +36 -36
- package/dist/cli/commands/migrateRun.d.ts +2 -2
- package/dist/cli/commands/migrateRun.js +34 -34
- package/dist/cli/commands/migrateStatus.d.ts +1 -1
- package/dist/cli/commands/migrateStatus.js +16 -16
- package/dist/cli/eloquent.d.ts +1 -1
- package/dist/cli/eloquent.js +30 -30
- package/dist/cli/utils/ArtifactRoutingReport.d.ts +1 -1
- package/dist/cli/utils/ArtifactRoutingReport.js +3 -3
- package/dist/cli/utils/ArtifactStorage.d.ts +2 -2
- package/dist/cli/utils/ArtifactStorage.js +17 -17
- package/dist/cli/utils/AuditTrail.js +2 -2
- package/dist/cli/utils/CliBootstrapSupport.d.ts +1 -1
- package/dist/cli/utils/CliCommandTargets.d.ts +2 -2
- package/dist/cli/utils/CliCommandTargets.js +2 -2
- package/dist/cli/utils/CliMakeArtifactCommandRegistration.js +15 -15
- package/dist/cli/utils/CliMigrationCommandRegistration.js +29 -29
- package/dist/cli/utils/CliProductionGuards.d.ts +1 -1
- package/dist/cli/utils/CliProductionGuards.js +6 -6
- package/dist/cli/utils/CliScaffoldCommandRegistration.js +13 -13
- package/dist/cli/utils/CliSeedScenarioCommandRegistration.js +23 -23
- package/dist/cli/utils/CliSupportCommandRegistration.js +8 -8
- package/dist/cli/utils/ImportResolver.d.ts +12 -3
- package/dist/cli/utils/ImportResolver.js +76 -17
- package/dist/cli/utils/ModelIntrospector.d.ts +1 -1
- package/dist/cli/utils/ModelIntrospector.js +4 -4
- package/dist/cli/utils/ScaffoldGeneratorSupport.js +2 -2
- package/dist/cli/utils/ScenarioMorphAliasRouting.js +8 -8
- package/dist/cli/utils/SeedBootstrapPrecheck.d.ts +1 -1
- package/dist/cli/utils/SeedBootstrapPrecheck.js +10 -10
- package/dist/cli/utils/TemplateEngine.js +2 -2
- package/dist/cli/utils/factories/Factory.d.ts +1 -1
- package/dist/cli/utils/factories/FactoryDisplay.d.ts +1 -1
- package/dist/cli/utils/factories/FactoryGraph.js +5 -5
- package/dist/cli/utils/factories/FactoryLoader.d.ts +1 -1
- package/dist/cli/utils/factories/FactoryLoader.js +4 -4
- package/dist/cli/utils/factories/FactoryRegistry.d.ts +3 -3
- package/dist/cli/utils/factories/FactoryRegistry.js +10 -10
- package/dist/cli/utils/migrations/MigrationLockStrategy.d.ts +1 -1
- package/dist/cli/utils/migrations/MigrationLockStrategy.js +2 -2
- package/dist/cli/utils/migrations/MigrationTracker.d.ts +2 -2
- package/dist/cli/utils/migrations/MigrationTracker.js +6 -6
- package/dist/cli/utils/migrations/MongoMigrationTracker.js +3 -3
- package/dist/cli/utils/resolveConnectionFlags.d.ts +1 -1
- package/dist/cli/utils/resolveConnectionFlags.js +3 -3
- package/dist/cli/utils/resolveSqlConnectionFlags.d.ts +1 -1
- package/dist/cli/utils/typescript/BaseCommand.d.ts +1 -1
- package/dist/cli/utils/typescript/BaseCommand.js +3 -3
- package/dist/cli/utils/typescript/tsRuntime.js +62 -9
- package/dist/config/database.js +9 -9
- package/dist/core/cache/CacheFallbackManager.d.ts +1 -1
- package/dist/core/cache/CacheManager.d.ts +1 -1
- package/dist/core/cache/CacheManager.js +2 -2
- package/dist/core/cache/CacheRegistry.js +4 -4
- package/dist/core/cache/drivers/FileCacheDriver.d.ts +1 -1
- package/dist/core/cache/drivers/FileCacheDriver.js +2 -2
- package/dist/core/cache/drivers/MemcachedCacheDriver.d.ts +1 -1
- package/dist/core/cache/drivers/MemcachedCacheDriver.js +2 -2
- package/dist/core/cache/drivers/MemoryCacheDriver.d.ts +1 -1
- package/dist/core/cache/drivers/MemoryCacheDriver.js +2 -2
- package/dist/core/cache/setupCache.js +12 -12
- package/dist/core/connection/ConnectionFactory.d.ts +2 -2
- package/dist/core/connection/ConnectionFactory.js +9 -9
- package/dist/core/connection/DatabaseConnection.d.ts +2 -2
- package/dist/core/connection/DatabaseConnection.js +4 -4
- package/dist/core/connection/DriverAdapter.d.ts +1 -1
- package/dist/core/connection/DriverAdapter.js +2 -2
- package/dist/core/connection/resolveConnectionName.d.ts +1 -1
- package/dist/core/connection/resolveConnectionName.js +7 -7
- package/dist/core/model/BaseModel.d.ts +29 -29
- package/dist/core/model/BaseModel.js +38 -38
- package/dist/core/model/BaseModelSafeFinderStatics.d.ts +1 -1
- package/dist/core/model/BaseModelSafeFinderStatics.js +19 -19
- package/dist/core/model/CoreModel.d.ts +4 -4
- package/dist/core/model/CoreModel.js +28 -28
- package/dist/core/model/CoreModelPersistenceState.d.ts +1 -1
- package/dist/core/model/CoreModelSafeFinderSupport.d.ts +2 -2
- package/dist/core/model/CoreModelSafeFinderSupport.js +2 -2
- package/dist/core/model/CoreModelValidationEvents.d.ts +2 -2
- package/dist/core/model/CoreModelValidationEvents.js +2 -2
- package/dist/core/model/SafeFinder.d.ts +1 -1
- package/dist/core/model/SafeFinder.js +2 -2
- package/dist/core/orm/mixins/CastsMixin.js +2 -2
- package/dist/core/orm/mixins/HooksMixin.js +8 -8
- package/dist/core/orm/mixins/MorphableMixin.js +4 -4
- package/dist/core/orm/mixins/PivotHelperMixin.js +3 -3
- package/dist/core/orm/mixins/QueryCacheMixin.js +20 -20
- package/dist/core/orm/mixins/ScopeMixin.js +2 -2
- package/dist/core/orm/mixins/SoftDeletesMixin.js +2 -2
- package/dist/core/orm/mixins/utils/HookStore.d.ts +1 -1
- package/dist/core/orm/mixins/utils/HookStore.js +2 -2
- package/dist/core/orm/mixins/utils/modelRegistration.d.ts +1 -1
- package/dist/core/orm/mixins/utils/modelRegistration.js +6 -6
- package/dist/core/orm/relations/BelongsTo.d.ts +1 -1
- package/dist/core/orm/relations/BelongsTo.js +2 -2
- package/dist/core/orm/relations/BelongsToMany.d.ts +1 -1
- package/dist/core/orm/relations/BelongsToMany.js +2 -2
- package/dist/core/orm/relations/HasMany.d.ts +1 -1
- package/dist/core/orm/relations/HasMany.js +2 -2
- package/dist/core/orm/relations/HasOne.d.ts +1 -1
- package/dist/core/orm/relations/HasOne.js +2 -2
- package/dist/core/orm/relations/MorphMany.d.ts +1 -1
- package/dist/core/orm/relations/MorphMany.js +2 -2
- package/dist/core/orm/relations/MorphOne.d.ts +1 -1
- package/dist/core/orm/relations/MorphOne.js +2 -2
- package/dist/core/orm/relations/MorphTo.d.ts +1 -1
- package/dist/core/orm/relations/MorphTo.js +5 -5
- package/dist/core/schema/SchemaBuilder.d.ts +2 -2
- package/dist/core/schema/SchemaBuilder.js +9 -9
- package/dist/core/schema/SchemaValidator.d.ts +1 -1
- package/dist/core/security/AbstractSecurity.d.ts +1 -1
- package/dist/core/security/EnvKeySecurity.d.ts +1 -1
- package/dist/core/security/EnvKeySecurity.js +2 -2
- package/dist/core/security/NoSecurity.d.ts +1 -1
- package/dist/core/security/NoSecurity.js +2 -2
- package/dist/core/security/SecurityFactory.d.ts +1 -1
- package/dist/core/security/SecurityFactory.js +4 -4
- package/dist/core/security/index.d.ts +5 -5
- package/dist/core/security/index.js +5 -5
- package/dist/index.d.ts +10 -10
- package/dist/index.js +30 -30
- package/esm/Factory.mjs +113 -136
- package/esm/Model.mjs +4 -0
- package/esm/index.mjs +23 -28
- package/package.json +14 -5
- package/src/cli/templates/factory.tpl +1 -1
- package/src/cli/templates/seed.tpl +1 -1
|
@@ -7,24 +7,24 @@ exports.makeScenario = makeScenario;
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
10
|
+
const PathMap_js_1 = require("../utils/PathMap.js");
|
|
11
|
+
const makeFactory_js_1 = require("./makeFactory.js");
|
|
12
|
+
const makeController_js_1 = require("./makeController.js");
|
|
13
|
+
const makeService_js_1 = require("./makeService.js");
|
|
14
|
+
const makeMigration_js_1 = require("./makeMigration.js");
|
|
15
|
+
const migrateFresh_js_1 = require("./migrateFresh.js");
|
|
16
|
+
const dbSeed_js_1 = require("./dbSeed.js");
|
|
17
|
+
const ImportResolver_js_1 = require("../utils/ImportResolver.js");
|
|
18
|
+
const resolveConnectionFlags_js_1 = require("../utils/resolveConnectionFlags.js");
|
|
19
|
+
const resolveConnectionName_js_1 = require("../../core/connection/resolveConnectionName.js");
|
|
20
|
+
const tsRuntime_js_1 = require("../utils/typescript/tsRuntime.js");
|
|
21
21
|
function clearRequireCache(filePath) {
|
|
22
|
-
(0,
|
|
22
|
+
(0, tsRuntime_js_1.clearLoadedModuleCache)(path_1.default.resolve(filePath));
|
|
23
23
|
}
|
|
24
24
|
function clearScenarioArtifactModuleCache(isTest) {
|
|
25
|
-
const modelsDir =
|
|
26
|
-
const factoriesDir =
|
|
27
|
-
const seedsDir =
|
|
25
|
+
const modelsDir = PathMap_js_1.PathMap.models(isTest);
|
|
26
|
+
const factoriesDir = PathMap_js_1.PathMap.factories(isTest);
|
|
27
|
+
const seedsDir = PathMap_js_1.PathMap.seeds(isTest);
|
|
28
28
|
for (const modelName of scenarioManagedModelNames()) {
|
|
29
29
|
clearRequireCache(path_1.default.join(modelsDir, `${modelName}.ts`));
|
|
30
30
|
clearRequireCache(path_1.default.join(modelsDir, `${modelName}.js`));
|
|
@@ -43,8 +43,8 @@ function clearScenarioArtifactModuleCache(isTest) {
|
|
|
43
43
|
function renderModel(spec, options) {
|
|
44
44
|
const attrs = spec.attrs.map((line) => ` ${line}`).join("\n");
|
|
45
45
|
const schema = spec.schemaLines.map((line) => ` ${line}`).join("\n");
|
|
46
|
-
const coreImportPath =
|
|
47
|
-
const schemaImportPath =
|
|
46
|
+
const coreImportPath = ImportResolver_js_1.ImportResolver.coreImportPath(options.isTest, PathMap_js_1.PathMap.root);
|
|
47
|
+
const schemaImportPath = ImportResolver_js_1.ImportResolver.schemaImportPath(options.isTest, PathMap_js_1.PathMap.root);
|
|
48
48
|
const modelBaseClass = options.useMongo ? "MongoModel" : "SqlModel";
|
|
49
49
|
const connectionExpr = options.useMongo
|
|
50
50
|
? `"${options.defaultConnectionName}"`
|
|
@@ -372,7 +372,7 @@ const mediaPreset = {
|
|
|
372
372
|
};
|
|
373
373
|
const presets = [blogPreset, mediaPreset];
|
|
374
374
|
function scenarioManifestPath(isTest) {
|
|
375
|
-
return path_1.default.resolve(
|
|
375
|
+
return path_1.default.resolve(PathMap_js_1.PathMap.root, isTest ? "src/test/.eloquent-scenario.json" : "src/app/.eloquent-scenario.json");
|
|
376
376
|
}
|
|
377
377
|
function escapeRegex(value) {
|
|
378
378
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -435,12 +435,12 @@ function cleanupScenarioArtifacts(isTest) {
|
|
|
435
435
|
const tableNames = [...scenarioManagedTables(), ...scenarioManagedPivotTables()];
|
|
436
436
|
const migrationPattern = new RegExp(`^\\d+_(create|update)_(${tableNames.map(escapeRegex).join("|")})_table\\.(ts|js)$`);
|
|
437
437
|
const manifestPath = scenarioManifestPath(isTest);
|
|
438
|
-
const modelsDir =
|
|
439
|
-
const factoriesDir =
|
|
440
|
-
const seedsDir =
|
|
441
|
-
const controllersDir = path_1.default.resolve(
|
|
442
|
-
const servicesDir = path_1.default.resolve(
|
|
443
|
-
const migrationsRoot =
|
|
438
|
+
const modelsDir = PathMap_js_1.PathMap.models(isTest);
|
|
439
|
+
const factoriesDir = PathMap_js_1.PathMap.factories(isTest);
|
|
440
|
+
const seedsDir = PathMap_js_1.PathMap.seeds(isTest);
|
|
441
|
+
const controllersDir = path_1.default.resolve(PathMap_js_1.PathMap.root, isTest ? "src/test/controllers" : "src/app/controllers");
|
|
442
|
+
const servicesDir = path_1.default.resolve(PathMap_js_1.PathMap.root, isTest ? "src/test/services" : "src/app/services");
|
|
443
|
+
const migrationsRoot = PathMap_js_1.PathMap.migrations(isTest);
|
|
444
444
|
for (const modelName of modelNames) {
|
|
445
445
|
removedCount += Number(removeFileIfExists(path_1.default.join(modelsDir, `${modelName}.ts`)));
|
|
446
446
|
removedCount += Number(removeFileIfExists(path_1.default.join(factoriesDir, `${modelName}Factory.ts`)));
|
|
@@ -486,13 +486,13 @@ function selectPreset(name) {
|
|
|
486
486
|
async function makeScenario(name, options = {}) {
|
|
487
487
|
const isTest = options.test === true;
|
|
488
488
|
const useMongo = options.mongo === true;
|
|
489
|
-
const connectionNames = (0,
|
|
489
|
+
const connectionNames = (0, resolveConnectionFlags_js_1.resolveConnectionNamesFromFlags)(isTest, {
|
|
490
490
|
mongo: useMongo,
|
|
491
491
|
});
|
|
492
492
|
if (useMongo && connectionNames.length === 0) {
|
|
493
493
|
throw new Error("No mongo test connection configured. Set DB_TEST_CONNECTION=mongo_test or configure mongo_test in dbConfig.");
|
|
494
494
|
}
|
|
495
|
-
const scenarioConnectionName = connectionNames[0] ?? (0,
|
|
495
|
+
const scenarioConnectionName = connectionNames[0] ?? (0, resolveConnectionName_js_1.resolveConnectionName)(undefined, { test: isTest });
|
|
496
496
|
const renderOptions = {
|
|
497
497
|
isTest,
|
|
498
498
|
useMongo,
|
|
@@ -513,12 +513,12 @@ async function makeScenario(name, options = {}) {
|
|
|
513
513
|
console.log(chalk_1.default.yellow(`Force cleanup removed ${removedArtifacts} stale scenario artifact(s).`));
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
|
-
|
|
517
|
-
const modelsDir =
|
|
518
|
-
const factoriesDir =
|
|
519
|
-
const seedsDir =
|
|
520
|
-
const controllersDir = path_1.default.resolve(
|
|
521
|
-
const servicesDir = path_1.default.resolve(
|
|
516
|
+
PathMap_js_1.PathMap.ensureDirs();
|
|
517
|
+
const modelsDir = PathMap_js_1.PathMap.models(isTest);
|
|
518
|
+
const factoriesDir = PathMap_js_1.PathMap.factories(isTest);
|
|
519
|
+
const seedsDir = PathMap_js_1.PathMap.seeds(isTest);
|
|
520
|
+
const controllersDir = path_1.default.resolve(PathMap_js_1.PathMap.root, isTest ? "src/test/controllers" : "src/app/controllers");
|
|
521
|
+
const servicesDir = path_1.default.resolve(PathMap_js_1.PathMap.root, isTest ? "src/test/services" : "src/app/services");
|
|
522
522
|
if (!fs_1.default.existsSync(controllersDir)) {
|
|
523
523
|
fs_1.default.mkdirSync(controllersDir, { recursive: true });
|
|
524
524
|
}
|
|
@@ -531,30 +531,36 @@ async function makeScenario(name, options = {}) {
|
|
|
531
531
|
}
|
|
532
532
|
// 2) Factories
|
|
533
533
|
for (const model of preset.models) {
|
|
534
|
-
await (0,
|
|
534
|
+
await (0, makeFactory_js_1.makeFactory)(model.name, { test: isTest, force: true, mongo: useMongo });
|
|
535
535
|
}
|
|
536
536
|
if (options.controllers) {
|
|
537
537
|
for (const model of preset.models) {
|
|
538
|
-
await (0,
|
|
538
|
+
await (0, makeController_js_1.makeController)(model.name, { test: isTest });
|
|
539
539
|
}
|
|
540
540
|
}
|
|
541
541
|
if (options.services) {
|
|
542
542
|
for (const model of preset.models) {
|
|
543
|
-
await (0,
|
|
543
|
+
await (0, makeService_js_1.makeService)(model.name, { test: isTest });
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
546
|
// 3) Seeder (custom scenario)
|
|
547
547
|
const seederPath = path_1.default.join(seedsDir, `${preset.seedName}.ts`);
|
|
548
|
+
const userFactoryImportPath = ImportResolver_js_1.ImportResolver.withRuntimeRelativeImportExtension("../factories/UserFactory", PathMap_js_1.PathMap.root);
|
|
549
|
+
const commentFactoryImportPath = ImportResolver_js_1.ImportResolver.withRuntimeRelativeImportExtension("../factories/CommentFactory", PathMap_js_1.PathMap.root);
|
|
550
|
+
const extraFactoryImports = preset.id === "media"
|
|
551
|
+
? [
|
|
552
|
+
`import { PhotoFactory } from "${ImportResolver_js_1.ImportResolver.withRuntimeRelativeImportExtension("../factories/PhotoFactory", PathMap_js_1.PathMap.root)}";`,
|
|
553
|
+
`import { VideoFactory } from "${ImportResolver_js_1.ImportResolver.withRuntimeRelativeImportExtension("../factories/VideoFactory", PathMap_js_1.PathMap.root)}";`,
|
|
554
|
+
].join("\n")
|
|
555
|
+
: `import { PostFactory } from "${ImportResolver_js_1.ImportResolver.withRuntimeRelativeImportExtension("../factories/PostFactory", PathMap_js_1.PathMap.root)}";`;
|
|
548
556
|
const seedContent = `/**
|
|
549
557
|
* Auto-generated Scenario Seeder
|
|
550
558
|
* Seeder: ${preset.seedName}
|
|
551
559
|
*/
|
|
552
560
|
|
|
553
|
-
import { UserFactory } from "
|
|
554
|
-
import { CommentFactory } from "
|
|
555
|
-
${
|
|
556
|
-
? 'import { PhotoFactory } from "../factories/PhotoFactory";\nimport { VideoFactory } from "../factories/VideoFactory";'
|
|
557
|
-
: 'import { PostFactory } from "../factories/PostFactory";'}
|
|
561
|
+
import { UserFactory } from "${userFactoryImportPath}";
|
|
562
|
+
import { CommentFactory } from "${commentFactoryImportPath}";
|
|
563
|
+
${extraFactoryImports}
|
|
558
564
|
|
|
559
565
|
type SeedModel = {
|
|
560
566
|
id?: number;
|
|
@@ -612,18 +618,18 @@ export async function ${preset.seedName}() {
|
|
|
612
618
|
writeScenarioManifest(isTest, preset);
|
|
613
619
|
clearScenarioArtifactModuleCache(isTest);
|
|
614
620
|
// 4) Migrations
|
|
615
|
-
await (0,
|
|
621
|
+
await (0, makeMigration_js_1.makeMigration)("all", {
|
|
616
622
|
test: isTest,
|
|
617
623
|
exit: false,
|
|
618
624
|
connectionName: scenarioConnectionName,
|
|
619
625
|
});
|
|
620
626
|
if (options.run) {
|
|
621
|
-
await (0,
|
|
627
|
+
await (0, migrateFresh_js_1.migrateFresh)({
|
|
622
628
|
test: isTest,
|
|
623
629
|
force: true,
|
|
624
630
|
connectionNames: [scenarioConnectionName],
|
|
625
631
|
});
|
|
626
|
-
await (0,
|
|
632
|
+
await (0, dbSeed_js_1.dbSeed)({
|
|
627
633
|
test: isTest,
|
|
628
634
|
class: preset.seedName,
|
|
629
635
|
close: true,
|
|
@@ -6,34 +6,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.makeSeed = makeSeed;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
9
|
+
const TemplateEngine_js_1 = require("../utils/TemplateEngine.js");
|
|
10
|
+
const PathMap_js_1 = require("../utils/PathMap.js");
|
|
11
|
+
const ImportResolver_js_1 = require("../utils/ImportResolver.js");
|
|
12
|
+
const fileWriter_js_1 = require("../utils/fileWriter.js");
|
|
12
13
|
/**
|
|
13
14
|
* makeSeed
|
|
14
15
|
* Generates a seeder for a given model (with its factory)
|
|
15
16
|
*/
|
|
16
17
|
async function makeSeed(name, options) {
|
|
17
18
|
try {
|
|
18
|
-
|
|
19
|
+
PathMap_js_1.PathMap.ensureDirs();
|
|
19
20
|
const ModelName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
20
21
|
const FactoryName = `${ModelName}Factory`;
|
|
21
22
|
const SeederName = `${ModelName}Seeder`;
|
|
22
23
|
const Count = options?.count ?? 10;
|
|
23
24
|
const Timestamp = new Date().toISOString();
|
|
24
|
-
const
|
|
25
|
-
const
|
|
25
|
+
const factoryImportPath = ImportResolver_js_1.ImportResolver.withRuntimeRelativeImportExtension(`../factories/${FactoryName}`, PathMap_js_1.PathMap.root);
|
|
26
|
+
const template = TemplateEngine_js_1.TemplateEngine.load("seed");
|
|
27
|
+
const rendered = TemplateEngine_js_1.TemplateEngine.render(template, {
|
|
26
28
|
SeederName,
|
|
27
29
|
FactoryName,
|
|
28
30
|
ModelName,
|
|
29
31
|
Count,
|
|
30
32
|
Timestamp,
|
|
33
|
+
factoryImportPath,
|
|
31
34
|
});
|
|
32
|
-
const outputDir =
|
|
35
|
+
const outputDir = PathMap_js_1.PathMap.seeds(!!options?.test);
|
|
33
36
|
const filePath = path_1.default.resolve(outputDir, `${SeederName}.ts`);
|
|
34
37
|
const ok = options?.force
|
|
35
|
-
? (0,
|
|
36
|
-
: (0,
|
|
38
|
+
? (0, fileWriter_js_1.overwriteFile)(filePath, rendered)
|
|
39
|
+
: (0, fileWriter_js_1.writeFileSafe)(filePath, rendered);
|
|
37
40
|
if (ok) {
|
|
38
41
|
console.log(chalk_1.default.greenBright(`OK: Seeder created: ${SeederName}`));
|
|
39
42
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeService = makeService;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const TemplateEngine_js_1 = require("../utils/TemplateEngine.js");
|
|
5
|
+
const fileWriter_js_1 = require("../utils/fileWriter.js");
|
|
6
|
+
const ScaffoldGeneratorSupport_js_1 = require("../utils/ScaffoldGeneratorSupport.js");
|
|
7
7
|
async function makeService(modelName, options = {}) {
|
|
8
8
|
try {
|
|
9
9
|
const isTest = !!options.test;
|
|
10
10
|
const forceWrite = !!options.force;
|
|
11
|
-
const artifact = (0,
|
|
11
|
+
const artifact = (0, ScaffoldGeneratorSupport_js_1.resolveScaffoldArtifact)("service", modelName, { test: isTest });
|
|
12
12
|
const modelImportPath = isTest
|
|
13
13
|
? `../database/models/${artifact.modelClassName}`
|
|
14
14
|
: `../models/${artifact.modelClassName}`;
|
|
15
|
-
const template =
|
|
16
|
-
const rendered =
|
|
15
|
+
const template = TemplateEngine_js_1.TemplateEngine.load("service");
|
|
16
|
+
const rendered = TemplateEngine_js_1.TemplateEngine.render(template, {
|
|
17
17
|
ModelName: artifact.modelClassName,
|
|
18
18
|
modelImportPath,
|
|
19
19
|
});
|
|
20
20
|
const created = forceWrite
|
|
21
|
-
? (0,
|
|
22
|
-
: (0,
|
|
21
|
+
? (0, fileWriter_js_1.overwriteFile)(artifact.outputPath, rendered)
|
|
22
|
+
: (0, fileWriter_js_1.writeFileSafe)(artifact.outputPath, rendered);
|
|
23
23
|
if (created) {
|
|
24
|
-
(0,
|
|
24
|
+
(0, ScaffoldGeneratorSupport_js_1.logScaffoldCreated)("service", artifact.relativePath);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
catch (err) {
|
|
28
|
-
(0,
|
|
28
|
+
(0, ScaffoldGeneratorSupport_js_1.logScaffoldFailure)("service", modelName, err);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -6,31 +6,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.migrateFresh = migrateFresh;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const readline_1 = __importDefault(require("readline"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
9
|
+
const migrateRun_js_1 = require("./migrateRun.js");
|
|
10
|
+
const makeMigration_js_1 = require("./makeMigration.js");
|
|
11
|
+
const ConnectionFactory_js_1 = require("../../core/connection/ConnectionFactory.js");
|
|
12
|
+
const resolveConnectionName_js_1 = require("../../core/connection/resolveConnectionName.js");
|
|
13
|
+
const database_js_1 = require("../../config/database.js");
|
|
14
14
|
async function getMongoConnection(connectionName) {
|
|
15
|
-
if (typeof
|
|
16
|
-
return (await (0,
|
|
15
|
+
if (typeof ConnectionFactory_js_1.getConnection === "function") {
|
|
16
|
+
return (await (0, ConnectionFactory_js_1.getConnection)(connectionName));
|
|
17
17
|
}
|
|
18
18
|
// Test harness compatibility: some command-level mocks only provide getAdapter.
|
|
19
|
-
return (await
|
|
19
|
+
return (await ConnectionFactory_js_1.getAdapter(connectionName));
|
|
20
20
|
}
|
|
21
21
|
async function finalizeDropAllTables(connectionName, success, error) {
|
|
22
22
|
if (!success) {
|
|
23
23
|
console.error(chalk_1.default.red(`Error while dropping tables for ${connectionName}:`));
|
|
24
24
|
console.error(error);
|
|
25
25
|
}
|
|
26
|
-
await (0,
|
|
26
|
+
await (0, ConnectionFactory_js_1.closeAllConnections)();
|
|
27
27
|
return success;
|
|
28
28
|
}
|
|
29
29
|
async function dropAllTablesForConnection(connectionName) {
|
|
30
30
|
let success = false;
|
|
31
31
|
let failure;
|
|
32
32
|
try {
|
|
33
|
-
const driver =
|
|
33
|
+
const driver = database_js_1.dbConfig.connections[connectionName]?.driver;
|
|
34
34
|
if (driver === "mongo") {
|
|
35
35
|
const db = await getMongoConnection(connectionName);
|
|
36
36
|
console.log(chalk_1.default.gray(`Connected to ${connectionName}.`));
|
|
@@ -44,7 +44,7 @@ async function dropAllTablesForConnection(connectionName) {
|
|
|
44
44
|
success = true;
|
|
45
45
|
return await finalizeDropAllTables(connectionName, success);
|
|
46
46
|
}
|
|
47
|
-
const db = await (0,
|
|
47
|
+
const db = await (0, ConnectionFactory_js_1.getAdapter)(connectionName);
|
|
48
48
|
console.log(chalk_1.default.gray(`Connected to ${connectionName}.`));
|
|
49
49
|
if (driver === "pg") {
|
|
50
50
|
const tables = await db.query(`SELECT tablename
|
|
@@ -92,7 +92,7 @@ async function migrateFresh(options = {}) {
|
|
|
92
92
|
const isTest = !!options.test;
|
|
93
93
|
const connectionNames = options.connectionNames && options.connectionNames.length > 0
|
|
94
94
|
? options.connectionNames
|
|
95
|
-
: [(0,
|
|
95
|
+
: [(0, resolveConnectionName_js_1.resolveConnectionName)(undefined, { test: isTest })];
|
|
96
96
|
const confirmed = options?.force === true ? true : await confirmDangerousAction();
|
|
97
97
|
if (!confirmed) {
|
|
98
98
|
console.log(chalk_1.default.yellow("\nOperation cancelled by user.\n"));
|
|
@@ -108,7 +108,7 @@ async function migrateFresh(options = {}) {
|
|
|
108
108
|
if (options.allMigrations) {
|
|
109
109
|
for (const connectionName of connectionNames) {
|
|
110
110
|
try {
|
|
111
|
-
await (0,
|
|
111
|
+
await (0, makeMigration_js_1.makeMigration)("all", {
|
|
112
112
|
test: isTest,
|
|
113
113
|
connectionName,
|
|
114
114
|
exit: false,
|
|
@@ -124,7 +124,7 @@ async function migrateFresh(options = {}) {
|
|
|
124
124
|
}
|
|
125
125
|
// Keep the legacy combined line for integration-test compatibility.
|
|
126
126
|
console.log(chalk_1.default.yellow("All tables dropped. Re-running migrations..."));
|
|
127
|
-
await (0,
|
|
127
|
+
await (0, migrateRun_js_1.migrateRun)(isTest, undefined, false, false, {
|
|
128
128
|
connectionNames,
|
|
129
129
|
auditCommand: options.auditCommand ?? "migrate:fresh",
|
|
130
130
|
});
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.migrateReset = migrateReset;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const migrateRollback_js_1 = require("./migrateRollback.js");
|
|
9
|
+
const resolveConnectionName_js_1 = require("../../core/connection/resolveConnectionName.js");
|
|
10
10
|
/**
|
|
11
11
|
* migrate:reset
|
|
12
12
|
* Rolls back all migrations completely (every batch).
|
|
@@ -15,9 +15,9 @@ async function migrateReset(options = {}) {
|
|
|
15
15
|
const isTest = !!options.test;
|
|
16
16
|
const connectionNames = options.connectionNames && options.connectionNames.length > 0
|
|
17
17
|
? options.connectionNames
|
|
18
|
-
: [(0,
|
|
18
|
+
: [(0, resolveConnectionName_js_1.resolveConnectionName)(undefined, { test: isTest })];
|
|
19
19
|
console.log(chalk_1.default.cyan(`\nRESET: ${isTest ? "test" : "development"} database (all batches) on ${connectionNames.join(", ")}...\n`));
|
|
20
|
-
await (0,
|
|
20
|
+
await (0, migrateRollback_js_1.migrateRollback)({
|
|
21
21
|
test: isTest,
|
|
22
22
|
connectionNames,
|
|
23
23
|
allMigrations: options.allMigrations ?? true,
|
|
@@ -7,14 +7,14 @@ exports.migrateRollback = migrateRollback;
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
10
|
+
const ConnectionFactory_js_1 = require("../../core/connection/ConnectionFactory.js");
|
|
11
|
+
const PathMap_js_1 = require("../utils/PathMap.js");
|
|
12
|
+
const database_js_1 = require("../../config/database.js");
|
|
13
|
+
const resolveConnectionName_js_1 = require("../../core/connection/resolveConnectionName.js");
|
|
14
|
+
const MigrationTracker_js_1 = require("../utils/migrations/MigrationTracker.js");
|
|
15
|
+
const MongoMigrationTracker_js_1 = require("../utils/migrations/MongoMigrationTracker.js");
|
|
16
|
+
const tsRuntime_js_1 = require("../utils/typescript/tsRuntime.js");
|
|
17
|
+
const AuditTrail_js_1 = require("../utils/AuditTrail.js");
|
|
18
18
|
function createMongoMigrationContext(db) {
|
|
19
19
|
const collectionExists = async (name) => {
|
|
20
20
|
const rows = await db
|
|
@@ -49,21 +49,21 @@ function createMongoMigrationContext(db) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
async function getMongoConnection(connectionName) {
|
|
52
|
-
if (typeof
|
|
53
|
-
return (await (0,
|
|
52
|
+
if (typeof ConnectionFactory_js_1.getConnection === "function") {
|
|
53
|
+
return (await (0, ConnectionFactory_js_1.getConnection)(connectionName));
|
|
54
54
|
}
|
|
55
55
|
// Test harness compatibility: some command-level mocks only provide getAdapter.
|
|
56
|
-
return (await
|
|
56
|
+
return (await ConnectionFactory_js_1.getAdapter(connectionName));
|
|
57
57
|
}
|
|
58
58
|
async function rollbackConnection(connectionName, isTest, step) {
|
|
59
59
|
const stepLabel = step === Number.MAX_SAFE_INTEGER ? "all" : String(step);
|
|
60
60
|
console.log(chalk_1.default.cyan(`\nRolling back migrations in ${isTest ? "TEST" : "DEVELOPMENT"} mode on "${connectionName}" (step ${stepLabel})...\n`));
|
|
61
|
-
const migrationsDir =
|
|
61
|
+
const migrationsDir = PathMap_js_1.PathMap.migrations(isTest, connectionName);
|
|
62
62
|
if (!fs_1.default.existsSync(migrationsDir)) {
|
|
63
63
|
console.log(chalk_1.default.yellow(`No migrations directory found for ${connectionName}.`));
|
|
64
64
|
return true;
|
|
65
65
|
}
|
|
66
|
-
const driver =
|
|
66
|
+
const driver = database_js_1.dbConfig.connections[connectionName]?.driver ?? connectionName;
|
|
67
67
|
if (driver === "mongo") {
|
|
68
68
|
const db = await getMongoConnection(connectionName);
|
|
69
69
|
console.log(chalk_1.default.gray(`Connected to ${connectionName}.`));
|
|
@@ -71,10 +71,10 @@ async function rollbackConnection(connectionName, isTest, step) {
|
|
|
71
71
|
let lockAcquired = false;
|
|
72
72
|
let completedWithoutError = false;
|
|
73
73
|
try {
|
|
74
|
-
await (0,
|
|
75
|
-
await (0,
|
|
74
|
+
await (0, MongoMigrationTracker_js_1.ensureMigrationCollection)(db);
|
|
75
|
+
await (0, MongoMigrationTracker_js_1.acquireMigrationLock)(db, lockOwner);
|
|
76
76
|
lockAcquired = true;
|
|
77
|
-
const rows = (await (0,
|
|
77
|
+
const rows = (await (0, MongoMigrationTracker_js_1.validateMigrationHistory)(db, migrationsDir))
|
|
78
78
|
.map((row) => ({ id: row.id, name: row.name, batch: row.batch }))
|
|
79
79
|
.sort((a, b) => {
|
|
80
80
|
if (b.batch !== a.batch)
|
|
@@ -100,10 +100,10 @@ async function rollbackConnection(connectionName, isTest, step) {
|
|
|
100
100
|
const migrationFile = entry.name;
|
|
101
101
|
const filePath = path_1.default.join(migrationsDir, migrationFile);
|
|
102
102
|
if (!fs_1.default.existsSync(filePath)) {
|
|
103
|
-
const fallbackCollection = (0,
|
|
103
|
+
const fallbackCollection = (0, MigrationTracker_js_1.getAutoGeneratedCreateTableName)(migrationFile);
|
|
104
104
|
if (fallbackCollection) {
|
|
105
105
|
try {
|
|
106
|
-
const exists = await (0,
|
|
106
|
+
const exists = await (0, MongoMigrationTracker_js_1.doesCollectionExist)(db, fallbackCollection);
|
|
107
107
|
if (exists) {
|
|
108
108
|
await db.collection(fallbackCollection).drop();
|
|
109
109
|
console.log(chalk_1.default.yellow(`Fallback rollback: dropped collection "${fallbackCollection}" for missing migration file "${migrationFile}".`));
|
|
@@ -111,7 +111,7 @@ async function rollbackConnection(connectionName, isTest, step) {
|
|
|
111
111
|
else {
|
|
112
112
|
console.log(chalk_1.default.yellow(`Fallback rollback: collection "${fallbackCollection}" already absent for missing migration file "${migrationFile}".`));
|
|
113
113
|
}
|
|
114
|
-
await (0,
|
|
114
|
+
await (0, MongoMigrationTracker_js_1.deleteAppliedMigration)(db, migrationFile);
|
|
115
115
|
rolledBack++;
|
|
116
116
|
continue;
|
|
117
117
|
}
|
|
@@ -127,7 +127,7 @@ async function rollbackConnection(connectionName, isTest, step) {
|
|
|
127
127
|
break;
|
|
128
128
|
}
|
|
129
129
|
try {
|
|
130
|
-
const migrationModule = (0,
|
|
130
|
+
const migrationModule = (0, tsRuntime_js_1.loadModule)(path_1.default.resolve(filePath));
|
|
131
131
|
if (typeof migrationModule.down !== "function") {
|
|
132
132
|
console.log(chalk_1.default.gray(`No down() method: ${migrationFile}`));
|
|
133
133
|
continue;
|
|
@@ -135,7 +135,7 @@ async function rollbackConnection(connectionName, isTest, step) {
|
|
|
135
135
|
console.log(chalk_1.default.gray(`Reverting: ${migrationFile}`));
|
|
136
136
|
const context = createMongoMigrationContext(db);
|
|
137
137
|
await migrationModule.down(context);
|
|
138
|
-
await (0,
|
|
138
|
+
await (0, MongoMigrationTracker_js_1.deleteAppliedMigration)(db, migrationFile);
|
|
139
139
|
console.log(chalk_1.default.green(`Rolled back: ${migrationFile}`));
|
|
140
140
|
rolledBack++;
|
|
141
141
|
}
|
|
@@ -157,8 +157,8 @@ async function rollbackConnection(connectionName, isTest, step) {
|
|
|
157
157
|
/* c8 ignore next 4 -- ts-jest/v8 records a synthetic single-location branch on this finally block */
|
|
158
158
|
}
|
|
159
159
|
finally {
|
|
160
|
-
await (0,
|
|
161
|
-
await (0,
|
|
160
|
+
await (0, MongoMigrationTracker_js_1.releaseMigrationLock)(db, lockOwner);
|
|
161
|
+
await (0, ConnectionFactory_js_1.closeAllConnections)();
|
|
162
162
|
console.log(chalk_1.default.gray("All database connections closed.\n"));
|
|
163
163
|
}
|
|
164
164
|
}
|
|
@@ -166,7 +166,7 @@ async function rollbackConnection(connectionName, isTest, step) {
|
|
|
166
166
|
console.warn(chalk_1.default.yellow(`Rollback skipped: "${connectionName}" has unsupported driver "${driver}".`));
|
|
167
167
|
return true;
|
|
168
168
|
}
|
|
169
|
-
const db = await (0,
|
|
169
|
+
const db = await (0, ConnectionFactory_js_1.getAdapter)(connectionName);
|
|
170
170
|
console.log(chalk_1.default.gray(`Connected to ${connectionName}.`));
|
|
171
171
|
const lockOwner = `migrate:rollback:${connectionName}:${process.pid}:${Date.now()}`;
|
|
172
172
|
const runQuery = async (sql, params = []) => {
|
|
@@ -175,11 +175,11 @@ async function rollbackConnection(connectionName, isTest, step) {
|
|
|
175
175
|
let lockAcquired = false;
|
|
176
176
|
let completedWithoutError = false;
|
|
177
177
|
try {
|
|
178
|
-
await (0,
|
|
179
|
-
await (0,
|
|
178
|
+
await (0, MigrationTracker_js_1.ensureMigrationTables)(db);
|
|
179
|
+
await (0, MigrationTracker_js_1.acquireMigrationLock)(db, lockOwner);
|
|
180
180
|
lockAcquired = true;
|
|
181
181
|
let rows = [];
|
|
182
|
-
rows = (await (0,
|
|
182
|
+
rows = (await (0, MigrationTracker_js_1.validateMigrationHistory)(db, migrationsDir))
|
|
183
183
|
.map((row) => ({ id: row.id, name: row.name, batch: row.batch }))
|
|
184
184
|
/* c8 ignore next 4 -- ts-jest/v8 is not attributing this chained sort callback reliably in focused coverage */
|
|
185
185
|
.sort((a, b) => {
|
|
@@ -206,10 +206,10 @@ async function rollbackConnection(connectionName, isTest, step) {
|
|
|
206
206
|
const migrationFile = entry.name;
|
|
207
207
|
const filePath = path_1.default.join(migrationsDir, migrationFile);
|
|
208
208
|
if (!fs_1.default.existsSync(filePath)) {
|
|
209
|
-
const fallbackTable = (0,
|
|
209
|
+
const fallbackTable = (0, MigrationTracker_js_1.getAutoGeneratedCreateTableName)(migrationFile);
|
|
210
210
|
if (fallbackTable) {
|
|
211
211
|
try {
|
|
212
|
-
const exists = await (0,
|
|
212
|
+
const exists = await (0, MigrationTracker_js_1.doesMigrationTableExist)(db, fallbackTable);
|
|
213
213
|
if (exists) {
|
|
214
214
|
const dropSql = driver === "pg"
|
|
215
215
|
? `DROP TABLE IF EXISTS ${db.wrapId(fallbackTable)} CASCADE;`
|
|
@@ -220,7 +220,7 @@ async function rollbackConnection(connectionName, isTest, step) {
|
|
|
220
220
|
else {
|
|
221
221
|
console.log(chalk_1.default.yellow(`Fallback rollback: table "${fallbackTable}" already absent for missing migration file "${migrationFile}".`));
|
|
222
222
|
}
|
|
223
|
-
await (0,
|
|
223
|
+
await (0, MigrationTracker_js_1.deleteAppliedMigration)(db, migrationFile);
|
|
224
224
|
rolledBack++;
|
|
225
225
|
continue;
|
|
226
226
|
}
|
|
@@ -236,14 +236,14 @@ async function rollbackConnection(connectionName, isTest, step) {
|
|
|
236
236
|
break;
|
|
237
237
|
}
|
|
238
238
|
try {
|
|
239
|
-
const migrationModule = (0,
|
|
239
|
+
const migrationModule = (0, tsRuntime_js_1.loadModule)(path_1.default.resolve(filePath));
|
|
240
240
|
if (typeof migrationModule.down !== "function") {
|
|
241
241
|
console.log(chalk_1.default.gray(`No down() method: ${migrationFile}`));
|
|
242
242
|
continue;
|
|
243
243
|
}
|
|
244
244
|
console.log(chalk_1.default.gray(`Reverting: ${migrationFile}`));
|
|
245
245
|
await migrationModule.down({ query: runQuery });
|
|
246
|
-
await (0,
|
|
246
|
+
await (0, MigrationTracker_js_1.deleteAppliedMigration)(db, migrationFile);
|
|
247
247
|
console.log(chalk_1.default.green(`Rolled back: ${migrationFile}`));
|
|
248
248
|
rolledBack++;
|
|
249
249
|
}
|
|
@@ -265,8 +265,8 @@ async function rollbackConnection(connectionName, isTest, step) {
|
|
|
265
265
|
/* c8 ignore next 4 -- ts-jest/v8 records a synthetic single-location branch on this finally block */
|
|
266
266
|
}
|
|
267
267
|
finally {
|
|
268
|
-
await (0,
|
|
269
|
-
await (0,
|
|
268
|
+
await (0, MigrationTracker_js_1.releaseMigrationLock)(db, lockOwner, { success: completedWithoutError });
|
|
269
|
+
await (0, ConnectionFactory_js_1.closeAllConnections)();
|
|
270
270
|
console.log(chalk_1.default.gray("All database connections closed.\n"));
|
|
271
271
|
}
|
|
272
272
|
}
|
|
@@ -277,12 +277,12 @@ async function migrateRollback(options = {}) {
|
|
|
277
277
|
: Math.max(1, Number(options.step || 1));
|
|
278
278
|
const connectionNames = options.connectionNames && options.connectionNames.length > 0
|
|
279
279
|
? options.connectionNames
|
|
280
|
-
: [(0,
|
|
280
|
+
: [(0, resolveConnectionName_js_1.resolveConnectionName)(undefined, { test: isTest })];
|
|
281
281
|
let hadFailure = false;
|
|
282
282
|
const auditCommand = options.auditCommand ?? "migrate:rollback";
|
|
283
283
|
for (const connectionName of connectionNames) {
|
|
284
284
|
const success = await rollbackConnection(connectionName, isTest, step);
|
|
285
|
-
(0,
|
|
285
|
+
(0, AuditTrail_js_1.appendAuditEvent)({
|
|
286
286
|
command: auditCommand,
|
|
287
287
|
connectionName,
|
|
288
288
|
test: isTest,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ConnectionName } from "../../core/connection/ConnectionFactory";
|
|
2
|
-
import { resolveSqlConnectionNames, type SqlConnectionFlags } from "../utils/resolveSqlConnectionFlags";
|
|
1
|
+
import { type ConnectionName } from "../../core/connection/ConnectionFactory.js";
|
|
2
|
+
import { resolveSqlConnectionNames, type SqlConnectionFlags } from "../utils/resolveSqlConnectionFlags.js";
|
|
3
3
|
export type MigrateRunOptions = {
|
|
4
4
|
connectionNames?: ConnectionName[];
|
|
5
5
|
auditCommand?: string;
|