@javalabs/prisma-client 1.0.18 → 1.0.19
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/.dockerignore +14 -0
- package/Dockerfile +23 -0
- package/README.md +269 -269
- package/dist/index.d.ts +1 -1
- package/dist/prisma.service.d.ts +1 -1
- package/dist/scripts/add-uuid-to-table.js +32 -32
- package/dist/scripts/data-migration/batch-migrator.js +12 -12
- package/dist/scripts/data-migration/data-transformer.js +14 -14
- package/dist/scripts/data-migration/dependency-resolver.js +23 -23
- package/dist/scripts/data-migration/entity-discovery.js +68 -68
- package/dist/scripts/data-migration/foreign-key-manager.js +23 -23
- package/dist/scripts/data-migration/migration-tool.js +5 -5
- package/dist/scripts/data-migration/schema-utils.js +74 -74
- package/dist/scripts/data-migration/typecast-manager.js +4 -4
- package/dist/scripts/database-initializer.js +5 -5
- package/dist/scripts/drop-database.js +5 -5
- package/dist/scripts/fix-data-types.js +53 -53
- package/dist/scripts/fix-enum-values.js +34 -34
- package/dist/scripts/fix-schema-discrepancies.js +40 -40
- package/dist/scripts/fix-table-indexes.js +81 -81
- package/dist/scripts/migrate-schema-structure.js +4 -4
- package/dist/scripts/migrate-uuid.js +19 -19
- package/dist/scripts/post-migration-validator.js +49 -49
- package/dist/scripts/pre-migration-validator.js +107 -107
- package/dist/scripts/reset-database.js +21 -21
- package/dist/scripts/retry-failed-migrations.js +28 -28
- package/dist/scripts/run-migration.js +5 -5
- package/dist/scripts/schema-sync.js +18 -18
- package/dist/scripts/sequence-sync-cli.js +55 -55
- package/dist/scripts/sequence-synchronizer.js +20 -20
- package/dist/scripts/sync-enum-types.js +30 -30
- package/dist/scripts/sync-enum-values.js +52 -52
- package/dist/scripts/truncate-database.js +10 -10
- package/dist/scripts/verify-migration-setup.js +10 -10
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migration-config.json +63 -63
- package/migration-config.json.bk +95 -95
- package/package.json +44 -44
- package/prisma/migrations/add_accepts_partial_payments_to_users.sql +19 -0
- package/prisma/migrations/add_amount_received_to_manual_payments.sql +19 -0
- package/prisma/migrations/add_commission_fields.sql +33 -0
- package/prisma/migrations/add_uuid_to_transactions.sql +13 -13
- package/prisma/migrations/complete_partial_payments_migration.sql +53 -0
- package/prisma/migrations/create_settlements_table.sql +60 -0
- package/prisma/schema.prisma +47 -1
- package/src/index.ts +23 -23
- package/src/prisma-factory.service.ts +40 -40
- package/src/prisma.module.ts +9 -9
- package/src/prisma.service.ts +16 -16
- package/src/scripts/add-uuid-to-table.ts +138 -138
- package/src/scripts/create-tenant-schemas.ts +145 -145
- package/src/scripts/data-migration/batch-migrator.ts +248 -248
- package/src/scripts/data-migration/data-transformer.ts +426 -426
- package/src/scripts/data-migration/db-connector.ts +120 -120
- package/src/scripts/data-migration/dependency-resolver.ts +174 -174
- package/src/scripts/data-migration/entity-discovery.ts +196 -196
- package/src/scripts/data-migration/foreign-key-manager.ts +277 -277
- package/src/scripts/data-migration/migration-config.json +63 -63
- package/src/scripts/data-migration/migration-tool.ts +509 -509
- package/src/scripts/data-migration/schema-utils.ts +248 -248
- package/src/scripts/data-migration/tenant-migrator.ts +201 -201
- package/src/scripts/data-migration/typecast-manager.ts +193 -193
- package/src/scripts/data-migration/types.ts +113 -113
- package/src/scripts/database-initializer.ts +49 -49
- package/src/scripts/drop-database.ts +104 -104
- package/src/scripts/dump-source-db.sh +61 -61
- package/src/scripts/encrypt-user-passwords.ts +36 -36
- package/src/scripts/error-handler.ts +117 -117
- package/src/scripts/fix-data-types.ts +241 -241
- package/src/scripts/fix-enum-values.ts +357 -357
- package/src/scripts/fix-schema-discrepancies.ts +317 -317
- package/src/scripts/fix-table-indexes.ts +601 -601
- package/src/scripts/migrate-schema-structure.ts +90 -90
- package/src/scripts/migrate-uuid.ts +76 -76
- package/src/scripts/post-migration-validator.ts +526 -526
- package/src/scripts/pre-migration-validator.ts +610 -610
- package/src/scripts/reset-database.ts +263 -263
- package/src/scripts/retry-failed-migrations.ts +416 -416
- package/src/scripts/run-migration.ts +707 -707
- package/src/scripts/schema-sync.ts +128 -128
- package/src/scripts/sequence-sync-cli.ts +416 -416
- package/src/scripts/sequence-synchronizer.ts +127 -127
- package/src/scripts/sync-enum-types.ts +170 -170
- package/src/scripts/sync-enum-values.ts +563 -563
- package/src/scripts/truncate-database.ts +123 -123
- package/src/scripts/verify-migration-setup.ts +135 -135
- package/tsconfig.json +17 -17
- package/dist/scripts/data-migration/dependency-manager.d.ts +0 -9
- package/dist/scripts/data-migration/dependency-manager.js +0 -86
- package/dist/scripts/data-migration/dependency-manager.js.map +0 -1
- package/dist/scripts/data-migration/migration-config.json +0 -63
- package/dist/scripts/data-migration/migration-phases.d.ts +0 -5
- package/dist/scripts/data-migration/migration-phases.js +0 -55
- package/dist/scripts/data-migration/migration-phases.js.map +0 -1
- package/dist/scripts/data-migration/multi-source-migrator.d.ts +0 -17
- package/dist/scripts/data-migration/multi-source-migrator.js +0 -130
- package/dist/scripts/data-migration/multi-source-migrator.js.map +0 -1
- package/dist/scripts/data-migration/phase-generator.d.ts +0 -15
- package/dist/scripts/data-migration/phase-generator.js +0 -187
- package/dist/scripts/data-migration/phase-generator.js.map +0 -1
- package/dist/scripts/data-migration.d.ts +0 -22
- package/dist/scripts/data-migration.js +0 -593
- package/dist/scripts/data-migration.js.map +0 -1
- package/dist/scripts/multi-db-migration.d.ts +0 -1
- package/dist/scripts/multi-db-migration.js +0 -55
- package/dist/scripts/multi-db-migration.js.map +0 -1
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"commonSchema": "public",
|
|
3
|
-
"tenantInfo": {
|
|
4
|
-
"sourceTable": "users",
|
|
5
|
-
"tenantIdColumn": "user_id",
|
|
6
|
-
"providerIdColumn": "provider_id"
|
|
7
|
-
},
|
|
8
|
-
"migrationPriorities": {
|
|
9
|
-
"high": ["countries", "providers", "users", "api_keys"],
|
|
10
|
-
"medium": ["transactions", "charges", "balances"],
|
|
11
|
-
"low": ["invoices", "api_request_logs"]
|
|
12
|
-
},
|
|
13
|
-
"tables": {
|
|
14
|
-
"countries": {
|
|
15
|
-
"type": "public",
|
|
16
|
-
"idField": "id"
|
|
17
|
-
},
|
|
18
|
-
"providers": {
|
|
19
|
-
"type": "public",
|
|
20
|
-
"idField": "provider_id",
|
|
21
|
-
"dependencies": ["countries"]
|
|
22
|
-
},
|
|
23
|
-
"users": {
|
|
24
|
-
"type": "public",
|
|
25
|
-
"idField": "user_id",
|
|
26
|
-
"dependencies": ["providers"]
|
|
27
|
-
},
|
|
28
|
-
"api_keys": {
|
|
29
|
-
"type": "public",
|
|
30
|
-
"idField": "id",
|
|
31
|
-
"dependencies": ["users"]
|
|
32
|
-
},
|
|
33
|
-
"transactions": {
|
|
34
|
-
"type": "public",
|
|
35
|
-
"idField": "id",
|
|
36
|
-
"filterColumn": "provider_id",
|
|
37
|
-
"dependencies": ["users", "providers"]
|
|
38
|
-
},
|
|
39
|
-
"charges": {
|
|
40
|
-
"type": "public",
|
|
41
|
-
"idField": "id",
|
|
42
|
-
"filterColumn": "provider_id",
|
|
43
|
-
"dependencies": ["transactions"]
|
|
44
|
-
},
|
|
45
|
-
"invoices": {
|
|
46
|
-
"type": "public",
|
|
47
|
-
"idField": "id",
|
|
48
|
-
"filterColumn": "provider_id",
|
|
49
|
-
"dependencies": ["transactions", "charges"]
|
|
50
|
-
},
|
|
51
|
-
"balances": {
|
|
52
|
-
"type": "public",
|
|
53
|
-
"idField": "id",
|
|
54
|
-
"filterColumn": "provider_id",
|
|
55
|
-
"dependencies": ["users"]
|
|
56
|
-
},
|
|
57
|
-
"api_request_logs": {
|
|
58
|
-
"type": "public",
|
|
59
|
-
"idField": "id",
|
|
60
|
-
"dependencies": ["api_keys"]
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { MigrationPhase } from './types';
|
|
2
|
-
import { PrismaClient } from '@prisma/client';
|
|
3
|
-
export declare const defaultMigrationPhases: MigrationPhase[];
|
|
4
|
-
export declare function generateMigrationPhases(prisma: PrismaClient): Promise<MigrationPhase[]>;
|
|
5
|
-
export declare const migrationPhases: MigrationPhase[];
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.migrationPhases = exports.defaultMigrationPhases = void 0;
|
|
4
|
-
exports.generateMigrationPhases = generateMigrationPhases;
|
|
5
|
-
const phase_generator_1 = require("./phase-generator");
|
|
6
|
-
exports.defaultMigrationPhases = [
|
|
7
|
-
{
|
|
8
|
-
name: "Base Tables",
|
|
9
|
-
tables: ["users", "providers", "companies", "countries"],
|
|
10
|
-
required: true,
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
name: "Core Financial",
|
|
14
|
-
tables: ["balances", "banks"],
|
|
15
|
-
required: true,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
name: "Transactions",
|
|
19
|
-
tables: ["transactions", "global_user_transactions"],
|
|
20
|
-
required: true,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: "Transaction Related",
|
|
24
|
-
tables: ["transaction_updates", "daily_logs", "invoices"],
|
|
25
|
-
required: true,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: "Customer Data",
|
|
29
|
-
tables: ["customers", "charges", "credit_requests"],
|
|
30
|
-
required: true,
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: "Supporting Data",
|
|
34
|
-
tables: [
|
|
35
|
-
"notifications",
|
|
36
|
-
"api_keys",
|
|
37
|
-
"api_request_logs",
|
|
38
|
-
"pending_references",
|
|
39
|
-
"toku",
|
|
40
|
-
],
|
|
41
|
-
required: false,
|
|
42
|
-
},
|
|
43
|
-
];
|
|
44
|
-
async function generateMigrationPhases(prisma) {
|
|
45
|
-
const phaseGenerator = new phase_generator_1.PhaseGenerator(prisma);
|
|
46
|
-
try {
|
|
47
|
-
return await phaseGenerator.generatePhases();
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
console.error('Error generando fases de migración:', error);
|
|
51
|
-
return exports.defaultMigrationPhases;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.migrationPhases = exports.defaultMigrationPhases;
|
|
55
|
-
//# sourceMappingURL=migration-phases.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migration-phases.js","sourceRoot":"","sources":["../../../src/scripts/data-migration/migration-phases.ts"],"names":[],"mappings":";;;AA6CA,0DAQC;AApDD,uDAAmD;AAItC,QAAA,sBAAsB,GAAqB;IACtD;QACE,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC;QACxD,QAAQ,EAAE,IAAI;KACf;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD;QACE,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE,CAAC,cAAc,EAAE,0BAA0B,CAAC;QACpD,QAAQ,EAAE,IAAI;KACf;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,MAAM,EAAE,CAAC,qBAAqB,EAAE,YAAY,EAAE,UAAU,CAAC;QACzD,QAAQ,EAAE,IAAI;KACf;IACD;QACE,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,iBAAiB,CAAC;QACnD,QAAQ,EAAE,IAAI;KACf;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE;YACN,eAAe;YACf,UAAU;YACV,kBAAkB;YAClB,oBAAoB;YACpB,MAAM;SACP;QACD,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC;AAGK,KAAK,UAAU,uBAAuB,CAAC,MAAoB;IAChE,MAAM,cAAc,GAAG,IAAI,gCAAc,CAAC,MAAM,CAAC,CAAC;IAClD,IAAI,CAAC;QACH,OAAO,MAAM,cAAc,CAAC,cAAc,EAAE,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;QAC5D,OAAO,8BAAsB,CAAC;IAChC,CAAC;AACH,CAAC;AAGY,QAAA,eAAe,GAAG,8BAAsB,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DatabaseConnections } from "./types";
|
|
2
|
-
export declare class MultiSourceMigrator {
|
|
3
|
-
private readonly connections;
|
|
4
|
-
private readonly logger;
|
|
5
|
-
private readonly schemaUtils;
|
|
6
|
-
private readonly dataTransformers;
|
|
7
|
-
private readonly dependencyResolvers;
|
|
8
|
-
private readonly batchMigrators;
|
|
9
|
-
constructor(connections: DatabaseConnections);
|
|
10
|
-
migrateAllSources(options?: {
|
|
11
|
-
includeTables?: string[];
|
|
12
|
-
excludeTables?: string[];
|
|
13
|
-
}): Promise<void>;
|
|
14
|
-
private migrateTable;
|
|
15
|
-
private getPrimaryKeyForTable;
|
|
16
|
-
private ensureSchemaExists;
|
|
17
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MultiSourceMigrator = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const schema_utils_1 = require("./schema-utils");
|
|
6
|
-
const data_transformer_1 = require("./data-transformer");
|
|
7
|
-
const batch_migrator_1 = require("./batch-migrator");
|
|
8
|
-
const dependency_resolver_1 = require("./dependency-resolver");
|
|
9
|
-
class MultiSourceMigrator {
|
|
10
|
-
constructor(connections) {
|
|
11
|
-
this.connections = connections;
|
|
12
|
-
this.logger = new common_1.Logger("MultiSourceMigrator");
|
|
13
|
-
this.schemaUtils = new Map();
|
|
14
|
-
this.dataTransformers = new Map();
|
|
15
|
-
this.dependencyResolvers = new Map();
|
|
16
|
-
this.batchMigrators = new Map();
|
|
17
|
-
for (const sourceConn of connections.sourceConnections) {
|
|
18
|
-
const sourceId = sourceConn.sourceId;
|
|
19
|
-
const schemaUtil = new schema_utils_1.SchemaUtils(sourceConn.sourcePool, connections.targetPool);
|
|
20
|
-
this.schemaUtils.set(sourceId, schemaUtil);
|
|
21
|
-
const dataTransformer = new data_transformer_1.DataTransformer(schemaUtil);
|
|
22
|
-
this.dataTransformers.set(sourceId, dataTransformer);
|
|
23
|
-
const dependencyResolver = new dependency_resolver_1.DependencyResolver(sourceConn.sourcePool, connections.targetPool);
|
|
24
|
-
this.dependencyResolvers.set(sourceId, dependencyResolver);
|
|
25
|
-
const batchMigrator = new batch_migrator_1.BatchMigrator(schemaUtil, {
|
|
26
|
-
targetPool: connections.targetPool,
|
|
27
|
-
targetPrisma: connections.targetPrisma,
|
|
28
|
-
sourcePool: sourceConn.sourcePool,
|
|
29
|
-
sourcePrisma: sourceConn.sourcePrisma,
|
|
30
|
-
});
|
|
31
|
-
this.batchMigrators.set(sourceId, batchMigrator);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async migrateAllSources(options = {}) {
|
|
35
|
-
this.logger.log(`Iniciando migración desde ${this.connections.sourceConnections.length} fuentes de datos`);
|
|
36
|
-
for (const sourceConn of this.connections.sourceConnections) {
|
|
37
|
-
const sourceId = sourceConn.sourceId;
|
|
38
|
-
this.logger.log(`Procesando migración desde la fuente: ${sourceId}`);
|
|
39
|
-
try {
|
|
40
|
-
const dependencyResolver = this.dependencyResolvers.get(sourceId);
|
|
41
|
-
if (!dependencyResolver) {
|
|
42
|
-
throw new Error(`No se encontró DependencyResolver para la fuente ${sourceId}`);
|
|
43
|
-
}
|
|
44
|
-
const sortedTables = await dependencyResolver.analyzeDependencies();
|
|
45
|
-
let tablesToMigrate = sortedTables;
|
|
46
|
-
if (options.includeTables && options.includeTables.length > 0) {
|
|
47
|
-
tablesToMigrate = tablesToMigrate.filter((table) => options.includeTables.includes(table));
|
|
48
|
-
}
|
|
49
|
-
if (options.excludeTables && options.excludeTables.length > 0) {
|
|
50
|
-
tablesToMigrate = tablesToMigrate.filter((table) => !options.excludeTables.includes(table));
|
|
51
|
-
}
|
|
52
|
-
this.logger.log(`Migrando ${tablesToMigrate.length} tablas para la fuente ${sourceId}`);
|
|
53
|
-
for (const tableName of tablesToMigrate) {
|
|
54
|
-
await this.migrateTable(sourceId, tableName, 'public');
|
|
55
|
-
}
|
|
56
|
-
this.logger.log(`Migración completada para la fuente: ${sourceId}`);
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
this.logger.error(`Error en la migración de la fuente ${sourceId}: ${error.message}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
this.logger.log("Migración multi-origen completada");
|
|
63
|
-
}
|
|
64
|
-
async migrateTable(sourceId, tableName, targetSchema) {
|
|
65
|
-
try {
|
|
66
|
-
this.logger.log(`Migrando tabla ${tableName} desde la fuente ${sourceId} al schema ${targetSchema}`);
|
|
67
|
-
const batchMigrator = this.batchMigrators.get(sourceId);
|
|
68
|
-
if (!batchMigrator) {
|
|
69
|
-
throw new Error(`No se encontró BatchMigrator para la fuente ${sourceId}`);
|
|
70
|
-
}
|
|
71
|
-
const entity = {
|
|
72
|
-
name: tableName,
|
|
73
|
-
idField: await this.getPrimaryKeyForTable(sourceId, tableName),
|
|
74
|
-
};
|
|
75
|
-
const prisma = this.connections.targetPrisma;
|
|
76
|
-
await batchMigrator.migrateEntityDataInBatches(prisma, entity, null, 'public');
|
|
77
|
-
this.logger.log(`Migración de tabla ${tableName} completada`);
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
this.logger.error(`Error migrando tabla ${tableName} desde ${sourceId}: ${error.message}`);
|
|
81
|
-
throw error;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
async getPrimaryKeyForTable(sourceId, tableName) {
|
|
85
|
-
var _a;
|
|
86
|
-
const schemaUtil = this.schemaUtils.get(sourceId);
|
|
87
|
-
if (!schemaUtil) {
|
|
88
|
-
throw new Error(`No se encontró SchemaUtils para la fuente ${sourceId}`);
|
|
89
|
-
}
|
|
90
|
-
const query = `
|
|
91
|
-
SELECT a.attname
|
|
92
|
-
FROM pg_index i
|
|
93
|
-
JOIN pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey)
|
|
94
|
-
WHERE i.indrelid = '${tableName}'::regclass AND i.indisprimary;
|
|
95
|
-
`;
|
|
96
|
-
try {
|
|
97
|
-
const result = await ((_a = this.connections.sourceConnections
|
|
98
|
-
.find((conn) => conn.sourceId === sourceId)) === null || _a === void 0 ? void 0 : _a.sourcePool.query(query));
|
|
99
|
-
if (!result || result.rows.length === 0) {
|
|
100
|
-
throw new Error(`No se encontró clave primaria para la tabla ${tableName}`);
|
|
101
|
-
}
|
|
102
|
-
return result.rows[0].attname;
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
this.logger.error(`Error obteniendo clave primaria para ${tableName}: ${error.message}`);
|
|
106
|
-
return "id";
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
async ensureSchemaExists(schemaName) {
|
|
110
|
-
try {
|
|
111
|
-
const checkQuery = `
|
|
112
|
-
SELECT schema_name FROM information_schema.schemata
|
|
113
|
-
WHERE schema_name = $1
|
|
114
|
-
`;
|
|
115
|
-
const result = await this.connections.targetPool.query(checkQuery, [
|
|
116
|
-
schemaName,
|
|
117
|
-
]);
|
|
118
|
-
if (result.rows.length === 0) {
|
|
119
|
-
this.logger.log(`Creando esquema ${schemaName} en la base de datos destino`);
|
|
120
|
-
await this.connections.targetPool.query(`CREATE SCHEMA IF NOT EXISTS "${schemaName}"`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
this.logger.error(`Error al verificar/crear esquema ${schemaName}: ${error.message}`);
|
|
125
|
-
throw error;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
exports.MultiSourceMigrator = MultiSourceMigrator;
|
|
130
|
-
//# sourceMappingURL=multi-source-migrator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"multi-source-migrator.js","sourceRoot":"","sources":["../../../src/scripts/data-migration/multi-source-migrator.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,iDAA6C;AAC7C,yDAAqD;AAErD,qDAAiD;AACjD,+DAA2D;AAE3D,MAAa,mBAAmB;IAQ9B,YAA6B,WAAgC;QAAhC,gBAAW,GAAX,WAAW,CAAqB;QAP5C,WAAM,GAAG,IAAI,eAAM,CAAC,qBAAqB,CAAC,CAAC;QAC3C,gBAAW,GAA6B,IAAI,GAAG,EAAE,CAAC;QAClD,qBAAgB,GAAiC,IAAI,GAAG,EAAE,CAAC;QAC3D,wBAAmB,GAClC,IAAI,GAAG,EAAE,CAAC;QACK,mBAAc,GAA+B,IAAI,GAAG,EAAE,CAAC;QAItE,KAAK,MAAM,UAAU,IAAI,WAAW,CAAC,iBAAiB,EAAE,CAAC;YACvD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;YAGrC,MAAM,UAAU,GAAG,IAAI,0BAAW,CAChC,UAAU,CAAC,UAAU,EACrB,WAAW,CAAC,UAAU,CACvB,CAAC;YACF,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;YAG3C,MAAM,eAAe,GAAG,IAAI,kCAAe,CAAC,UAAU,CAAC,CAAC;YACxD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;YAGrD,MAAM,kBAAkB,GAAG,IAAI,wCAAkB,CAC/C,UAAU,CAAC,UAAU,EACrB,WAAW,CAAC,UAAU,CACvB,CAAC;YACF,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;YAG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AAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,wCAAwC,SAAS,KAAK,KAAK,CAAC,OAAO,EAAE,CACtE,CAAC;YAEF,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAAC,UAAkB;QACjD,IAAI,CAAC;YAEH,MAAM,UAAU,GAAG;;;OAGlB,CAAC;YACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,EAAE;gBACjE,UAAU;aACX,CAAC,CAAC;YAEH,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAE7B,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,mBAAmB,UAAU,8BAA8B,CAC5D,CAAC;gBACF,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CACrC,gCAAgC,UAAU,GAAG,CAC9C,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,oCAAoC,UAAU,KAAK,KAAK,CAAC,OAAO,EAAE,CACnE,CAAC;YACF,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAnND,kDAmNC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PrismaClient } from "@prisma/client";
|
|
2
|
-
import { MigrationPhase } from "./types";
|
|
3
|
-
export declare class PhaseGenerator {
|
|
4
|
-
private readonly logger;
|
|
5
|
-
private readonly prisma;
|
|
6
|
-
private readonly schemaPath;
|
|
7
|
-
constructor(prisma: PrismaClient);
|
|
8
|
-
generatePhases(): Promise<MigrationPhase[]>;
|
|
9
|
-
private runPrismaGenerate;
|
|
10
|
-
private extractRelations;
|
|
11
|
-
private buildDependencyGraph;
|
|
12
|
-
private createOrderedPhases;
|
|
13
|
-
private getPhaseDescription;
|
|
14
|
-
private getDefaultPhases;
|
|
15
|
-
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PhaseGenerator = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const fs = require("fs");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
const child_process_1 = require("child_process");
|
|
8
|
-
class PhaseGenerator {
|
|
9
|
-
constructor(prisma) {
|
|
10
|
-
this.logger = new common_1.Logger("PhaseGenerator");
|
|
11
|
-
this.prisma = prisma;
|
|
12
|
-
this.schemaPath = path.resolve(process.cwd(), "prisma/schema.prisma");
|
|
13
|
-
}
|
|
14
|
-
async generatePhases() {
|
|
15
|
-
try {
|
|
16
|
-
this.logger.log("Actualizando cliente Prisma...");
|
|
17
|
-
this.runPrismaGenerate();
|
|
18
|
-
this.logger.log("Analizando esquema de Prisma...");
|
|
19
|
-
const relations = await this.extractRelations();
|
|
20
|
-
const dependencyGraph = this.buildDependencyGraph(relations);
|
|
21
|
-
const orderedPhases = this.createOrderedPhases(dependencyGraph);
|
|
22
|
-
this.logger.log(`Generadas ${orderedPhases.length} fases de migración`);
|
|
23
|
-
return orderedPhases;
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
this.logger.error(`Error generando fases: ${error.message}`);
|
|
27
|
-
return this.getDefaultPhases();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
runPrismaGenerate() {
|
|
31
|
-
try {
|
|
32
|
-
(0, child_process_1.execSync)("npx prisma generate", { stdio: "inherit" });
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
this.logger.warn("Error ejecutando prisma generate, usando cliente existente");
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async extractRelations() {
|
|
39
|
-
const relations = new Map();
|
|
40
|
-
try {
|
|
41
|
-
const schemaContent = fs.readFileSync(this.schemaPath, "utf8");
|
|
42
|
-
const modelRegex = /model\s+(\w+)\s+{([^}]*)}/g;
|
|
43
|
-
const relationRegex = /@relation\(fields:\s*\[([^\]]+)\],\s*references:\s*\[([^\]]+)\]/g;
|
|
44
|
-
let modelMatch;
|
|
45
|
-
while ((modelMatch = modelRegex.exec(schemaContent)) !== null) {
|
|
46
|
-
const modelName = modelMatch[1].toLowerCase();
|
|
47
|
-
const modelBody = modelMatch[2];
|
|
48
|
-
if (!relations.has(modelName)) {
|
|
49
|
-
relations.set(modelName, new Set());
|
|
50
|
-
}
|
|
51
|
-
let relationMatch;
|
|
52
|
-
while ((relationMatch = relationRegex.exec(modelBody)) !== null) {
|
|
53
|
-
const referencedModelRegex = /(\w+)\s+(\w+)(\?)?\s+@relation/;
|
|
54
|
-
const lines = modelBody.split("\n");
|
|
55
|
-
for (const line of lines) {
|
|
56
|
-
if (line.includes("@relation") && line.includes(relationMatch[0])) {
|
|
57
|
-
const typeMatch = referencedModelRegex.exec(line);
|
|
58
|
-
if (typeMatch) {
|
|
59
|
-
const referencedModel = typeMatch[1].toLowerCase();
|
|
60
|
-
relations.get(modelName).add(referencedModel);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return relations;
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
this.logger.error(`Error extrayendo relaciones: ${error.message}`);
|
|
70
|
-
return new Map();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
buildDependencyGraph(relations) {
|
|
74
|
-
const graph = new Map();
|
|
75
|
-
for (const [model, _] of relations) {
|
|
76
|
-
if (!graph.has(model)) {
|
|
77
|
-
graph.set(model, new Set());
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
for (const [model, dependencies] of relations) {
|
|
81
|
-
for (const dependency of dependencies) {
|
|
82
|
-
if (!graph.has(dependency)) {
|
|
83
|
-
graph.set(dependency, new Set());
|
|
84
|
-
}
|
|
85
|
-
graph.get(dependency).add(model);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return graph;
|
|
89
|
-
}
|
|
90
|
-
createOrderedPhases(graph) {
|
|
91
|
-
const phases = [];
|
|
92
|
-
const visited = new Set();
|
|
93
|
-
const findBaseTables = () => {
|
|
94
|
-
const baseTables = [];
|
|
95
|
-
for (const [table, dependencies] of graph) {
|
|
96
|
-
if (!visited.has(table) && dependencies.size === 0) {
|
|
97
|
-
baseTables.push(table);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return baseTables;
|
|
101
|
-
};
|
|
102
|
-
let phaseNumber = 1;
|
|
103
|
-
let currentPhaseTables = findBaseTables();
|
|
104
|
-
while (currentPhaseTables.length > 0) {
|
|
105
|
-
for (const table of currentPhaseTables) {
|
|
106
|
-
visited.add(table);
|
|
107
|
-
}
|
|
108
|
-
phases.push({
|
|
109
|
-
name: `Phase ${phaseNumber}: ${this.getPhaseDescription(phaseNumber, currentPhaseTables)}`,
|
|
110
|
-
tables: currentPhaseTables,
|
|
111
|
-
required: phaseNumber <= 3
|
|
112
|
-
});
|
|
113
|
-
for (const [table, dependencies] of graph) {
|
|
114
|
-
for (const dependency of [...dependencies]) {
|
|
115
|
-
if (visited.has(dependency)) {
|
|
116
|
-
dependencies.delete(dependency);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
currentPhaseTables = findBaseTables();
|
|
121
|
-
phaseNumber++;
|
|
122
|
-
}
|
|
123
|
-
const remainingTables = [...graph.keys()].filter(table => !visited.has(table));
|
|
124
|
-
if (remainingTables.length > 0) {
|
|
125
|
-
this.logger.warn(`Tablas con dependencias circulares: ${remainingTables.join(", ")}`);
|
|
126
|
-
phases.push({
|
|
127
|
-
name: `Phase ${phaseNumber}: Circular Dependencies`,
|
|
128
|
-
tables: remainingTables,
|
|
129
|
-
required: false
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
return phases;
|
|
133
|
-
}
|
|
134
|
-
getPhaseDescription(phaseNumber, tables) {
|
|
135
|
-
if (phaseNumber === 1)
|
|
136
|
-
return "Base Tables";
|
|
137
|
-
if (tables.some(t => t.includes("transaction")))
|
|
138
|
-
return "Transactions";
|
|
139
|
-
if (tables.some(t => t.includes("user")))
|
|
140
|
-
return "User Data";
|
|
141
|
-
if (tables.some(t => t.includes("balance") || t.includes("bank")))
|
|
142
|
-
return "Financial";
|
|
143
|
-
return "Supporting Data";
|
|
144
|
-
}
|
|
145
|
-
getDefaultPhases() {
|
|
146
|
-
return [
|
|
147
|
-
{
|
|
148
|
-
name: "Base Tables",
|
|
149
|
-
tables: ["users", "providers", "companies", "countries"],
|
|
150
|
-
required: true,
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
name: "Core Financial",
|
|
154
|
-
tables: ["balances", "banks"],
|
|
155
|
-
required: true,
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
name: "Transactions",
|
|
159
|
-
tables: ["transactions", "global_user_transactions"],
|
|
160
|
-
required: true,
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
name: "Transaction Related",
|
|
164
|
-
tables: ["transaction_updates", "daily_logs", "invoices"],
|
|
165
|
-
required: true,
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: "Customer Data",
|
|
169
|
-
tables: ["customers", "charges", "credit_requests"],
|
|
170
|
-
required: true,
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
name: "Supporting Data",
|
|
174
|
-
tables: [
|
|
175
|
-
"notifications",
|
|
176
|
-
"api_keys",
|
|
177
|
-
"api_request_logs",
|
|
178
|
-
"pending_references",
|
|
179
|
-
"toku",
|
|
180
|
-
],
|
|
181
|
-
required: false,
|
|
182
|
-
},
|
|
183
|
-
];
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
exports.PhaseGenerator = PhaseGenerator;
|
|
187
|
-
//# sourceMappingURL=phase-generator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"phase-generator.js","sourceRoot":"","sources":["../../../src/scripts/data-migration/phase-generator.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAGxC,yBAAyB;AACzB,6BAA6B;AAC7B,iDAAyC;AAEzC,MAAa,cAAc;IAKzB,YAAY,MAAoB;QAJf,WAAM,GAAG,IAAI,eAAM,CAAC,gBAAgB,CAAC,CAAC;QAKrD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,sBAAsB,CAAC,CAAC;IACxE,CAAC;IAKD,KAAK,CAAC,cAAc;QAClB,IAAI,CAAC;YAEH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;YAClD,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAGzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;YACnD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAGhD,MAAM,eAAe,GAAG,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;YAG7D,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;YAEhE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,aAAa,CAAC,MAAM,qBAAqB,CAAC,CAAC;YACxE,OAAO,aAAa,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAE7D,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACjC,CAAC;IACH,CAAC;IAKO,iBAAiB;QACvB,IAAI,CAAC;YACH,IAAA,wBAAQ,EAAC,qB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AAI,EAAE,aAAa;gBACnB,MAAM,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC;gBACxD,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,gBAAgB;gBACtB,MAAM,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC;gBAC7B,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,cAAc;gBACpB,MAAM,EAAE,CAAC,cAAc,EAAE,0BAA0B,CAAC;gBACpD,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,qBAAqB;gBAC3B,MAAM,EAAE,CAAC,qBAAqB,EAAE,YAAY,EAAE,UAAU,CAAC;gBACzD,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,eAAe;gBACrB,MAAM,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,iBAAiB,CAAC;gBACnD,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,iBAAiB;gBACvB,MAAM,EAAE;oBACN,eAAe;oBACf,UAAU;oBACV,kBAAkB;oBAClB,oBAAoB;oBACpB,MAAM;iBACP;gBACD,QAAQ,EAAE,KAAK;aAChB;SACF,CAAC;IACJ,CAAC;CACF;AAnPD,wCAmPC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare class DataMigrationTool {
|
|
2
|
-
private readonly logger;
|
|
3
|
-
private readonly sourcePrisma;
|
|
4
|
-
private readonly targetPrisma;
|
|
5
|
-
private readonly sourcePool;
|
|
6
|
-
private readonly targetPool;
|
|
7
|
-
private schemaCache;
|
|
8
|
-
private targetSchemaCache;
|
|
9
|
-
private errorHandler;
|
|
10
|
-
constructor();
|
|
11
|
-
migrateData(): Promise<void>;
|
|
12
|
-
private migrateDataForTenant;
|
|
13
|
-
private getEnumValues;
|
|
14
|
-
private migrateEntityDataInBatches;
|
|
15
|
-
private discoverEntityTypes;
|
|
16
|
-
private checkSchemaExists;
|
|
17
|
-
private getTargetTables;
|
|
18
|
-
private upsertEntity;
|
|
19
|
-
private getTableSchema;
|
|
20
|
-
private cleanup;
|
|
21
|
-
private validateEnumValue;
|
|
22
|
-
}
|