@flusys/nestjs-core 8.1.4 → 9.1.0-rc.1
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/fesm/229.js
CHANGED
|
@@ -395,6 +395,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
395
395
|
vI: () => (/* binding */ runMigrations)
|
|
396
396
|
});
|
|
397
397
|
|
|
398
|
+
// UNUSED EXPORTS: stripIgnoredTableStatements
|
|
399
|
+
|
|
398
400
|
;// CONCATENATED MODULE: external "child_process"
|
|
399
401
|
|
|
400
402
|
;// CONCATENATED MODULE: external "fs"
|
|
@@ -473,8 +475,35 @@ async function generateMigration(config, name, tenantId, datasourcePath) {
|
|
|
473
475
|
},
|
|
474
476
|
cwd: process.cwd()
|
|
475
477
|
});
|
|
478
|
+
if (config.ignoreTable) {
|
|
479
|
+
const removed = stripIgnoredTableStatements(folder, name, config.ignoreTable);
|
|
480
|
+
if (removed > 0) {
|
|
481
|
+
console.log(`${label} Removed ${removed} statement(s) that touch runtime-managed tables`);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
476
484
|
console.log(`${label} ✓ Generated!`);
|
|
477
485
|
}
|
|
486
|
+
/**
|
|
487
|
+
* Removes every `queryRunner.query(...)` line of the just-generated migration whose SQL
|
|
488
|
+
* mentions an ignored table or index name. Returns how many statements were removed.
|
|
489
|
+
*/ function stripIgnoredTableStatements(folder, name, ignoreTable) {
|
|
490
|
+
const file = __rspack_external_fs.readdirSync(folder).filter((f)=>f.endsWith(`-${name}.ts`)).sort().pop();
|
|
491
|
+
if (!file) return 0;
|
|
492
|
+
const filePath = external_path_.join(folder, file);
|
|
493
|
+
const lines = __rspack_external_fs.readFileSync(filePath, 'utf8').split('\n');
|
|
494
|
+
let removed = 0;
|
|
495
|
+
const kept = lines.filter((line)=>{
|
|
496
|
+
if (!line.includes('queryRunner.query(')) return true;
|
|
497
|
+
const identifiers = [
|
|
498
|
+
...line.matchAll(/"([A-Za-z0-9_]+)"/g)
|
|
499
|
+
].map((m)=>m[1]);
|
|
500
|
+
const touches = identifiers.some(ignoreTable);
|
|
501
|
+
if (touches) removed++;
|
|
502
|
+
return !touches;
|
|
503
|
+
});
|
|
504
|
+
if (removed > 0) __rspack_external_fs.writeFileSync(filePath, kept.join('\n'));
|
|
505
|
+
return removed;
|
|
506
|
+
}
|
|
478
507
|
function findDatasourcePath() {
|
|
479
508
|
const possiblePaths = [
|
|
480
509
|
'src/persistence/migration.config.ts',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type IMigrationConfig, type IMigrationResult } from '../interfaces/migration.interface.js';
|
|
2
2
|
export declare function ensureMigrationsFolder(basePath: string, tenantId?: string): string;
|
|
3
3
|
export declare function generateMigration(config: IMigrationConfig, name: string, tenantId?: string, datasourcePath?: string): Promise<void>;
|
|
4
|
+
export declare function stripIgnoredTableStatements(folder: string, name: string, ignoreTable: (tableName: string) => boolean): number;
|
|
4
5
|
export declare function runMigrations(config: IMigrationConfig, tenantId?: string): Promise<IMigrationResult>;
|
|
5
6
|
export declare function revertMigration(config: IMigrationConfig, tenantId?: string): Promise<IMigrationResult>;
|
|
6
7
|
export declare function resetDatabase(config: IMigrationConfig, tenantId?: string): Promise<IMigrationResult>;
|