@javalabs/prisma-client 1.0.25 → 1.0.27
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/package.json +5 -5
- package/prisma/schema.prisma +0 -4
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -34
- package/dist/index.js.map +0 -1
- package/dist/prisma-factory.service.d.ts +0 -9
- package/dist/prisma-factory.service.js +0 -47
- package/dist/prisma-factory.service.js.map +0 -1
- package/dist/prisma.module.d.ts +0 -2
- package/dist/prisma.module.js +0 -23
- package/dist/prisma.module.js.map +0 -1
- package/dist/prisma.service.d.ts +0 -6
- package/dist/prisma.service.js +0 -27
- package/dist/prisma.service.js.map +0 -1
- package/dist/scripts/add-uuid-to-table.d.ts +0 -8
- package/dist/scripts/add-uuid-to-table.js +0 -98
- package/dist/scripts/add-uuid-to-table.js.map +0 -1
- package/dist/scripts/create-tenant-schemas.d.ts +0 -1
- package/dist/scripts/create-tenant-schemas.js +0 -117
- package/dist/scripts/create-tenant-schemas.js.map +0 -1
- package/dist/scripts/data-migration/batch-migrator.d.ts +0 -20
- package/dist/scripts/data-migration/batch-migrator.js +0 -134
- package/dist/scripts/data-migration/batch-migrator.js.map +0 -1
- package/dist/scripts/data-migration/data-transformer.d.ts +0 -26
- package/dist/scripts/data-migration/data-transformer.js +0 -278
- package/dist/scripts/data-migration/data-transformer.js.map +0 -1
- package/dist/scripts/data-migration/db-connector.d.ts +0 -12
- package/dist/scripts/data-migration/db-connector.js +0 -94
- package/dist/scripts/data-migration/db-connector.js.map +0 -1
- package/dist/scripts/data-migration/dependency-resolver.d.ts +0 -18
- package/dist/scripts/data-migration/dependency-resolver.js +0 -132
- package/dist/scripts/data-migration/dependency-resolver.js.map +0 -1
- package/dist/scripts/data-migration/entity-discovery.d.ts +0 -11
- package/dist/scripts/data-migration/entity-discovery.js +0 -152
- package/dist/scripts/data-migration/entity-discovery.js.map +0 -1
- package/dist/scripts/data-migration/foreign-key-manager.d.ts +0 -18
- package/dist/scripts/data-migration/foreign-key-manager.js +0 -160
- package/dist/scripts/data-migration/foreign-key-manager.js.map +0 -1
- package/dist/scripts/data-migration/migration-tool.d.ts +0 -48
- package/dist/scripts/data-migration/migration-tool.js +0 -290
- package/dist/scripts/data-migration/migration-tool.js.map +0 -1
- package/dist/scripts/data-migration/schema-utils.d.ts +0 -18
- package/dist/scripts/data-migration/schema-utils.js +0 -207
- package/dist/scripts/data-migration/schema-utils.js.map +0 -1
- package/dist/scripts/data-migration/tenant-migrator.d.ts +0 -15
- package/dist/scripts/data-migration/tenant-migrator.js +0 -117
- package/dist/scripts/data-migration/tenant-migrator.js.map +0 -1
- package/dist/scripts/data-migration/typecast-manager.d.ts +0 -9
- package/dist/scripts/data-migration/typecast-manager.js +0 -179
- package/dist/scripts/data-migration/typecast-manager.js.map +0 -1
- package/dist/scripts/data-migration/types.d.ts +0 -100
- package/dist/scripts/data-migration/types.js +0 -3
- package/dist/scripts/data-migration/types.js.map +0 -1
- package/dist/scripts/database-initializer.d.ts +0 -5
- package/dist/scripts/database-initializer.js +0 -45
- package/dist/scripts/database-initializer.js.map +0 -1
- package/dist/scripts/drop-database.d.ts +0 -10
- package/dist/scripts/drop-database.js +0 -81
- package/dist/scripts/drop-database.js.map +0 -1
- package/dist/scripts/encrypt-user-passwords.d.ts +0 -1
- package/dist/scripts/encrypt-user-passwords.js +0 -33
- package/dist/scripts/encrypt-user-passwords.js.map +0 -1
- package/dist/scripts/error-handler.d.ts +0 -12
- package/dist/scripts/error-handler.js +0 -82
- package/dist/scripts/error-handler.js.map +0 -1
- package/dist/scripts/fix-data-types.d.ts +0 -10
- package/dist/scripts/fix-data-types.js +0 -185
- package/dist/scripts/fix-data-types.js.map +0 -1
- package/dist/scripts/fix-enum-values.d.ts +0 -17
- package/dist/scripts/fix-enum-values.js +0 -234
- package/dist/scripts/fix-enum-values.js.map +0 -1
- package/dist/scripts/fix-schema-discrepancies.d.ts +0 -21
- package/dist/scripts/fix-schema-discrepancies.js +0 -240
- package/dist/scripts/fix-schema-discrepancies.js.map +0 -1
- package/dist/scripts/fix-table-indexes.d.ts +0 -26
- package/dist/scripts/fix-table-indexes.js +0 -460
- package/dist/scripts/fix-table-indexes.js.map +0 -1
- package/dist/scripts/migrate-schema-structure.d.ts +0 -1
- package/dist/scripts/migrate-schema-structure.js +0 -76
- package/dist/scripts/migrate-schema-structure.js.map +0 -1
- package/dist/scripts/migrate-uuid.d.ts +0 -2
- package/dist/scripts/migrate-uuid.js +0 -57
- package/dist/scripts/migrate-uuid.js.map +0 -1
- package/dist/scripts/post-migration-validator.d.ts +0 -34
- package/dist/scripts/post-migration-validator.js +0 -363
- package/dist/scripts/post-migration-validator.js.map +0 -1
- package/dist/scripts/pre-migration-validator.d.ts +0 -25
- package/dist/scripts/pre-migration-validator.js +0 -491
- package/dist/scripts/pre-migration-validator.js.map +0 -1
- package/dist/scripts/reset-database.d.ts +0 -17
- package/dist/scripts/reset-database.js +0 -202
- package/dist/scripts/reset-database.js.map +0 -1
- package/dist/scripts/retry-failed-migrations.d.ts +0 -14
- package/dist/scripts/retry-failed-migrations.js +0 -301
- package/dist/scripts/retry-failed-migrations.js.map +0 -1
- package/dist/scripts/run-migration.d.ts +0 -1
- package/dist/scripts/run-migration.js +0 -512
- package/dist/scripts/run-migration.js.map +0 -1
- package/dist/scripts/schema-sync.d.ts +0 -1
- package/dist/scripts/schema-sync.js +0 -85
- package/dist/scripts/schema-sync.js.map +0 -1
- package/dist/scripts/sequence-sync-cli.d.ts +0 -2
- package/dist/scripts/sequence-sync-cli.js +0 -287
- package/dist/scripts/sequence-sync-cli.js.map +0 -1
- package/dist/scripts/sequence-synchronizer.d.ts +0 -8
- package/dist/scripts/sequence-synchronizer.js +0 -88
- package/dist/scripts/sequence-synchronizer.js.map +0 -1
- package/dist/scripts/sync-enum-types.d.ts +0 -13
- package/dist/scripts/sync-enum-types.js +0 -139
- package/dist/scripts/sync-enum-types.js.map +0 -1
- package/dist/scripts/sync-enum-values.d.ts +0 -20
- package/dist/scripts/sync-enum-values.js +0 -336
- package/dist/scripts/sync-enum-values.js.map +0 -1
- package/dist/scripts/truncate-database.d.ts +0 -10
- package/dist/scripts/truncate-database.js +0 -100
- package/dist/scripts/truncate-database.js.map +0 -1
- package/dist/scripts/verify-migration-setup.d.ts +0 -11
- package/dist/scripts/verify-migration-setup.js +0 -120
- package/dist/scripts/verify-migration-setup.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/prisma/migrations/add_athena_match_fields.sql +0 -13
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const commander_1 = require("commander");
|
|
5
|
-
const dotenv_1 = require("dotenv");
|
|
6
|
-
const common_1 = require("@nestjs/common");
|
|
7
|
-
const pg_1 = require("pg");
|
|
8
|
-
const path = require("path");
|
|
9
|
-
const fs = require("fs");
|
|
10
|
-
(0, dotenv_1.config)();
|
|
11
|
-
const program = new commander_1.Command();
|
|
12
|
-
const logger = new common_1.Logger("SequenceSyncCLI");
|
|
13
|
-
program
|
|
14
|
-
.name("sequence-sync")
|
|
15
|
-
.description("Synchronize ID sequences in PostgreSQL database")
|
|
16
|
-
.option("-d, --database-url <url>", "Database connection URL", process.env.DATABASE_URL)
|
|
17
|
-
.option("--dry-run", "Show changes that would be made without applying them", false)
|
|
18
|
-
.option("-v, --verbose", "Show detailed information during execution", false)
|
|
19
|
-
.option("-t, --table <table>", "Synchronize a specific table", "")
|
|
20
|
-
.option("--priority <level>", "Synchronize tables of a specific priority (high, medium, low)", "")
|
|
21
|
-
.option("--fix", "Attempt to fix missing sequences", false);
|
|
22
|
-
program.parse(process.argv);
|
|
23
|
-
const options = program.opts();
|
|
24
|
-
if (!options.databaseUrl) {
|
|
25
|
-
logger.error("Database URL must be provided via --database-url or DATABASE_URL environment variable");
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
const configPath = path.join(__dirname, "data-migration", "migration-config.json");
|
|
29
|
-
let migrationConfig;
|
|
30
|
-
try {
|
|
31
|
-
migrationConfig = JSON.parse(fs.readFileSync(configPath, "utf8"));
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
logger.error("Error loading configuration file:", error.message);
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
async function findExistingSequence(pool, tableName, columnName) {
|
|
38
|
-
try {
|
|
39
|
-
const query = `
|
|
40
|
-
SELECT
|
|
41
|
-
s.relname as sequence_name
|
|
42
|
-
FROM pg_class s
|
|
43
|
-
JOIN pg_depend d ON d.objid = s.oid
|
|
44
|
-
JOIN pg_class t ON d.refobjid = t.oid
|
|
45
|
-
JOIN pg_attribute a ON (d.refobjid, d.refobjsubid) = (a.attrelid, a.attnum)
|
|
46
|
-
JOIN pg_namespace n ON n.oid = s.relnamespace
|
|
47
|
-
WHERE s.relkind = 'S'
|
|
48
|
-
AND n.nspname = 'public'
|
|
49
|
-
AND t.relname = $1
|
|
50
|
-
AND a.attname = $2;
|
|
51
|
-
`;
|
|
52
|
-
const result = await pool.query(query, [tableName, columnName]);
|
|
53
|
-
if (result.rows.length > 0) {
|
|
54
|
-
if (options.verbose) {
|
|
55
|
-
logger.log(`Found sequence for ${tableName}.${columnName}: ${result.rows[0].sequence_name}`);
|
|
56
|
-
}
|
|
57
|
-
return result.rows[0].sequence_name;
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
logger.error(`Error finding existing sequence for ${tableName}.${columnName}:`, error.message);
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
async function findOrCreateSequence(pool, tableName, columnName) {
|
|
67
|
-
try {
|
|
68
|
-
let sequenceName = await findExistingSequence(pool, tableName, columnName);
|
|
69
|
-
if (sequenceName) {
|
|
70
|
-
return sequenceName;
|
|
71
|
-
}
|
|
72
|
-
if (!options.fix) {
|
|
73
|
-
if (options.verbose) {
|
|
74
|
-
logger.log(`No sequence found for ${tableName}.${columnName} and --fix is not enabled`);
|
|
75
|
-
}
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
const possibleNames = [
|
|
79
|
-
`${tableName}_${columnName}_seq`,
|
|
80
|
-
`${tableName}_id_seq`,
|
|
81
|
-
`${tableName}_seq`,
|
|
82
|
-
];
|
|
83
|
-
for (const name of possibleNames) {
|
|
84
|
-
const exists = await pool.query(`
|
|
85
|
-
SELECT EXISTS (
|
|
86
|
-
SELECT 1 FROM pg_class c
|
|
87
|
-
JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
88
|
-
WHERE n.nspname = 'public'
|
|
89
|
-
AND c.relname = $1
|
|
90
|
-
AND c.relkind = 'S'
|
|
91
|
-
);
|
|
92
|
-
`, [name]);
|
|
93
|
-
if (exists.rows[0].exists) {
|
|
94
|
-
sequenceName = name;
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (!sequenceName) {
|
|
99
|
-
sequenceName = `${tableName}_${columnName}_seq`;
|
|
100
|
-
if (options.verbose) {
|
|
101
|
-
logger.log(`Creating new sequence: ${sequenceName}`);
|
|
102
|
-
}
|
|
103
|
-
const maxValQuery = `
|
|
104
|
-
SELECT COALESCE(MAX("${columnName}"), 0) as max_val
|
|
105
|
-
FROM "${tableName}";
|
|
106
|
-
`;
|
|
107
|
-
const maxValResult = await pool.query(maxValQuery);
|
|
108
|
-
const maxVal = parseInt(maxValResult.rows[0].max_val);
|
|
109
|
-
if (!options.dryRun) {
|
|
110
|
-
await pool.query(`
|
|
111
|
-
CREATE SEQUENCE IF NOT EXISTS "${sequenceName}"
|
|
112
|
-
START WITH ${maxVal + 1}
|
|
113
|
-
INCREMENT BY 1
|
|
114
|
-
NO MINVALUE
|
|
115
|
-
NO MAXVALUE
|
|
116
|
-
CACHE 1;
|
|
117
|
-
`);
|
|
118
|
-
await pool.query(`
|
|
119
|
-
ALTER TABLE "${tableName}"
|
|
120
|
-
ALTER COLUMN "${columnName}"
|
|
121
|
-
SET DEFAULT nextval('${sequenceName}'::regclass);
|
|
122
|
-
`);
|
|
123
|
-
logger.log(`✅ Sequence created and associated: ${sequenceName}`);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
logger.log(`[DRY-RUN] Would create sequence: ${sequenceName}`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return sequenceName;
|
|
130
|
-
}
|
|
131
|
-
catch (error) {
|
|
132
|
-
logger.error(`Error handling sequence for ${tableName}.${columnName}:`, error.message);
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
async function getTableInfo(pool, tableName, idField) {
|
|
137
|
-
try {
|
|
138
|
-
const tableExistsQuery = `
|
|
139
|
-
SELECT EXISTS (
|
|
140
|
-
SELECT 1
|
|
141
|
-
FROM information_schema.tables
|
|
142
|
-
WHERE table_schema = $1
|
|
143
|
-
AND table_name = $2
|
|
144
|
-
);
|
|
145
|
-
`;
|
|
146
|
-
const tableExists = await pool.query(tableExistsQuery, [
|
|
147
|
-
migrationConfig.commonSchema,
|
|
148
|
-
tableName,
|
|
149
|
-
]);
|
|
150
|
-
if (!tableExists.rows[0].exists) {
|
|
151
|
-
logger.warn(`Table ${tableName} does not exist in database`);
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
const sequenceName = await findOrCreateSequence(pool, tableName, idField);
|
|
155
|
-
const columnQuery = `
|
|
156
|
-
SELECT EXISTS (
|
|
157
|
-
SELECT 1 FROM pg_attrdef ad
|
|
158
|
-
JOIN pg_attribute a ON a.attrelid = ad.adrelid AND a.attnum = ad.adnum
|
|
159
|
-
WHERE a.attrelid = $1::regclass
|
|
160
|
-
AND a.attname = $2
|
|
161
|
-
AND (pg_get_expr(ad.adbin, ad.adrelid) LIKE 'nextval%' OR $3::text IS NOT NULL)
|
|
162
|
-
) as is_auto_increment;
|
|
163
|
-
`;
|
|
164
|
-
const columnResult = await pool.query(columnQuery, [
|
|
165
|
-
tableName,
|
|
166
|
-
idField,
|
|
167
|
-
sequenceName,
|
|
168
|
-
]);
|
|
169
|
-
return {
|
|
170
|
-
tableName,
|
|
171
|
-
primaryKeyColumn: idField,
|
|
172
|
-
sequenceName,
|
|
173
|
-
hasAutoIncrement: columnResult.rows[0].is_auto_increment,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
catch (error) {
|
|
177
|
-
logger.error(`Error getting table information for ${tableName}:`, error.message);
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
async function checkTableSequence(pool, tableName) {
|
|
182
|
-
try {
|
|
183
|
-
const tableConfig = migrationConfig.tables[tableName];
|
|
184
|
-
if (!tableConfig) {
|
|
185
|
-
logger.warn(`No configuration found for table ${tableName}`);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
const tableInfo = await getTableInfo(pool, tableName, tableConfig.idField);
|
|
189
|
-
if (!tableInfo)
|
|
190
|
-
return;
|
|
191
|
-
if (!tableInfo.hasAutoIncrement || !tableInfo.sequenceName) {
|
|
192
|
-
if (options.verbose) {
|
|
193
|
-
logger.log(`\nTable ${tableInfo.tableName}:`);
|
|
194
|
-
logger.log(`- Primary key column: ${tableInfo.primaryKeyColumn}`);
|
|
195
|
-
logger.log(`- Does not use automatic sequence`);
|
|
196
|
-
}
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
if (options.verbose) {
|
|
200
|
-
logger.log(`\nTable information:`);
|
|
201
|
-
logger.log(`- Table name: ${tableInfo.tableName}`);
|
|
202
|
-
logger.log(`- Primary key column: ${tableInfo.primaryKeyColumn}`);
|
|
203
|
-
logger.log(`- Sequence: ${tableInfo.sequenceName}`);
|
|
204
|
-
}
|
|
205
|
-
const maxIdResult = await pool.query(`
|
|
206
|
-
SELECT COALESCE(MAX("${tableInfo.primaryKeyColumn}"), 0) as max_id
|
|
207
|
-
FROM "${tableInfo.tableName}";
|
|
208
|
-
`);
|
|
209
|
-
const maxId = parseInt(maxIdResult.rows[0].max_id);
|
|
210
|
-
const seqResult = await pool.query(`
|
|
211
|
-
SELECT last_value, is_called
|
|
212
|
-
FROM "${tableInfo.sequenceName}";
|
|
213
|
-
`);
|
|
214
|
-
const currentSeqValue = parseInt(seqResult.rows[0].last_value);
|
|
215
|
-
const isCalled = seqResult.rows[0].is_called;
|
|
216
|
-
logger.log(`\nDiagnostics for table ${tableInfo.tableName}:`);
|
|
217
|
-
logger.log(`- Maximum ID in table (${tableInfo.primaryKeyColumn}): ${maxId}`);
|
|
218
|
-
logger.log(`- Current sequence value: ${currentSeqValue}`);
|
|
219
|
-
logger.log(`- Sequence has been called: ${isCalled}`);
|
|
220
|
-
if (currentSeqValue <= maxId) {
|
|
221
|
-
logger.log(`\n⚠️ Problem detected! Sequence is behind maximum ID`);
|
|
222
|
-
if (!options.dryRun) {
|
|
223
|
-
await pool.query(`SELECT setval($1, $2, true);`, [
|
|
224
|
-
tableInfo.sequenceName,
|
|
225
|
-
maxId,
|
|
226
|
-
]);
|
|
227
|
-
logger.log(`✅ Sequence updated to value ${maxId}`);
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
logger.log(`[DRY-RUN] Would update sequence to value ${maxId}`);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
logger.log(`✅ Sequence is properly configured`);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
catch (error) {
|
|
238
|
-
logger.error(`Error processing table ${tableName}:`, error.message);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
async function main() {
|
|
242
|
-
try {
|
|
243
|
-
logger.log("Starting sequence synchronization...");
|
|
244
|
-
logger.log(`Database URL: ${options.databaseUrl.split("@")[1]}`);
|
|
245
|
-
if (options.dryRun) {
|
|
246
|
-
logger.log("Dry-run mode: No changes will be made");
|
|
247
|
-
}
|
|
248
|
-
const pool = new pg_1.Pool({ connectionString: options.databaseUrl });
|
|
249
|
-
if (options.table) {
|
|
250
|
-
await checkTableSequence(pool, options.table);
|
|
251
|
-
}
|
|
252
|
-
else if (options.priority) {
|
|
253
|
-
const tables = migrationConfig.migrationPriorities[options.priority];
|
|
254
|
-
if (!tables) {
|
|
255
|
-
logger.error(`Invalid priority: ${options.priority}`);
|
|
256
|
-
process.exit(1);
|
|
257
|
-
}
|
|
258
|
-
for (const table of tables) {
|
|
259
|
-
if (options.verbose) {
|
|
260
|
-
logger.log(`\nProcessing ${options.priority} priority table: ${table}`);
|
|
261
|
-
}
|
|
262
|
-
await checkTableSequence(pool, table);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
const allTables = [
|
|
267
|
-
...migrationConfig.migrationPriorities.high,
|
|
268
|
-
...migrationConfig.migrationPriorities.medium,
|
|
269
|
-
...migrationConfig.migrationPriorities.low,
|
|
270
|
-
];
|
|
271
|
-
for (const table of allTables) {
|
|
272
|
-
if (options.verbose) {
|
|
273
|
-
logger.log(`\nProcessing table: ${table}`);
|
|
274
|
-
}
|
|
275
|
-
await checkTableSequence(pool, table);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
await pool.end();
|
|
279
|
-
logger.log("\nSequence synchronization completed successfully");
|
|
280
|
-
}
|
|
281
|
-
catch (error) {
|
|
282
|
-
logger.error("Error during synchronization:", error.stack);
|
|
283
|
-
process.exit(1);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
main();
|
|
287
|
-
//# sourceMappingURL=sequence-sync-cli.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sequence-sync-cli.js","sourceRoot":"","sources":["../../src/scripts/sequence-sync-cli.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,mCAAgC;AAChC,2CAAwC;AACxC,2BAA0B;AAC1B,6BAA6B;AAC7B,yBAAyB;AAGzB,IAAA,eAAM,GAAE,CAAC;AA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,CAAC,IAAI;gBAC3C,GAAG,eAAe,CAAC,mBAAmB,CAAC,MAAM;gBAC7C,GAAG,eAAe,CAAC,mBAAmB,CAAC,GAAG;aAC3C,CAAC;YAEF,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;gBAC9B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;oBACpB,MAAM,CAAC,GAAG,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAC;gBAC7C,CAAC;gBACD,MAAM,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YACxC,CAAC;QACH,CAAC;QAED,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;QACjB,MAAM,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;IAClE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SequenceSynchronizer = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const pg_1 = require("pg");
|
|
6
|
-
class SequenceSynchronizer {
|
|
7
|
-
constructor(databaseUrl) {
|
|
8
|
-
this.logger = new common_1.Logger("SequenceSynchronizer");
|
|
9
|
-
this.pool = new pg_1.Pool({
|
|
10
|
-
connectionString: databaseUrl,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
async synchronizeSequences() {
|
|
14
|
-
try {
|
|
15
|
-
this.logger.log("Iniciando sincronización de secuencias");
|
|
16
|
-
const tables = await this.getTables();
|
|
17
|
-
this.logger.log(`Encontradas ${tables.length} tablas para procesar`);
|
|
18
|
-
for (const table of tables) {
|
|
19
|
-
await this.synchronizeTableSequences(table);
|
|
20
|
-
}
|
|
21
|
-
this.logger.log("Sincronización de secuencias completada con éxito");
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
this.logger.error(`Error durante la sincronización de secuencias: ${error.message}`, error.stack);
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
finally {
|
|
28
|
-
await this.pool.end();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
async getTables() {
|
|
32
|
-
const query = `
|
|
33
|
-
SELECT table_name
|
|
34
|
-
FROM information_schema.tables
|
|
35
|
-
WHERE table_schema = 'public'
|
|
36
|
-
AND table_type = 'BASE TABLE'
|
|
37
|
-
`;
|
|
38
|
-
const result = await this.pool.query(query);
|
|
39
|
-
return result.rows.map((row) => row.table_name);
|
|
40
|
-
}
|
|
41
|
-
async synchronizeTableSequences(tableName) {
|
|
42
|
-
try {
|
|
43
|
-
const columns = await this.pool.query(`
|
|
44
|
-
SELECT column_name
|
|
45
|
-
FROM information_schema.columns
|
|
46
|
-
WHERE table_name = $1
|
|
47
|
-
AND column_name = 'id'
|
|
48
|
-
`, [tableName]);
|
|
49
|
-
if (columns.rows.length === 0) {
|
|
50
|
-
this.logger.debug(`La tabla ${tableName} no tiene columna id, omitiendo`);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const sequenceName = `${tableName}_id_seq`;
|
|
54
|
-
const sequences = await this.pool.query(`
|
|
55
|
-
SELECT sequence_name
|
|
56
|
-
FROM information_schema.sequences
|
|
57
|
-
WHERE sequence_name = $1
|
|
58
|
-
`, [sequenceName]);
|
|
59
|
-
if (sequences.rows.length === 0) {
|
|
60
|
-
this.logger.debug(`No se encontró secuencia para la tabla ${tableName}, omitiendo`);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const maxResult = await this.pool.query(`
|
|
64
|
-
SELECT COALESCE(MAX(id), 0) as max_id FROM "${tableName}"
|
|
65
|
-
`);
|
|
66
|
-
const maxId = maxResult.rows[0].max_id;
|
|
67
|
-
const currValResult = await this.pool.query(`
|
|
68
|
-
SELECT last_value FROM "${sequenceName}"
|
|
69
|
-
`);
|
|
70
|
-
const currVal = currValResult.rows[0].last_value;
|
|
71
|
-
this.logger.log(`Tabla ${tableName}: ID Máximo = ${maxId}, Valor Actual de Secuencia = ${currVal}`);
|
|
72
|
-
if (currVal <= maxId) {
|
|
73
|
-
await this.pool.query(`
|
|
74
|
-
SELECT setval($1, $2, true)
|
|
75
|
-
`, [sequenceName, maxId]);
|
|
76
|
-
this.logger.log(`Actualizada secuencia para tabla ${tableName} a ${maxId}`);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
this.logger.log(`La secuencia para la tabla ${tableName} ya está adelantada al ID máximo, no se requiere actualización`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
this.logger.error(`Error sincronizando secuencias para tabla ${tableName}: ${error.message}`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
exports.SequenceSynchronizer = SequenceSynchronizer;
|
|
88
|
-
//# sourceMappingURL=sequence-synchronizer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sequence-synchronizer.js","sourceRoot":"","sources":["../../src/scripts/sequence-synchronizer.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,2BAA0B;AAE1B,MAAa,oBAAoB;IAI/B,YAAY,WAAmB;QAHd,WAAM,GAAG,IAAI,eAAM,CAAC,sBAAsB,CAAC,CAAC;QAI3D,IAAI,CAAC,IAAI,GAAG,IAAI,SAAI,CAAC;YACnB,gBAAgB,EAAE,WAAW;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;YAG1D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,E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@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare class EnumSynchronizer {
|
|
2
|
-
private readonly sourceUrl;
|
|
3
|
-
private readonly targetUrl;
|
|
4
|
-
private readonly logger;
|
|
5
|
-
private readonly sourcePool;
|
|
6
|
-
private readonly targetPool;
|
|
7
|
-
constructor(sourceUrl?: string, targetUrl?: string);
|
|
8
|
-
synchronizeEnums(): Promise<void>;
|
|
9
|
-
private synchronizeEnumType;
|
|
10
|
-
private createEnumType;
|
|
11
|
-
private updateEnumValues;
|
|
12
|
-
private cleanup;
|
|
13
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EnumSynchronizer = void 0;
|
|
4
|
-
const pg = require("pg");
|
|
5
|
-
const dotenv = require("dotenv");
|
|
6
|
-
const common_1 = require("@nestjs/common");
|
|
7
|
-
dotenv.config();
|
|
8
|
-
class EnumSynchronizer {
|
|
9
|
-
constructor(sourceUrl = process.env.SOURCE_DATABASE_URL, targetUrl = process.env.DATABASE_URL) {
|
|
10
|
-
this.sourceUrl = sourceUrl;
|
|
11
|
-
this.targetUrl = targetUrl;
|
|
12
|
-
this.logger = new common_1.Logger('EnumSynchronizer');
|
|
13
|
-
this.sourcePool = new pg.Pool({
|
|
14
|
-
connectionString: this.sourceUrl,
|
|
15
|
-
});
|
|
16
|
-
this.targetPool = new pg.Pool({
|
|
17
|
-
connectionString: this.targetUrl,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
async synchronizeEnums() {
|
|
21
|
-
try {
|
|
22
|
-
this.logger.log('Starting enum synchronization');
|
|
23
|
-
const sourceEnumsResult = await this.sourcePool.query(`
|
|
24
|
-
SELECT t.typname AS enum_name
|
|
25
|
-
FROM pg_type t
|
|
26
|
-
JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
|
|
27
|
-
WHERE t.typtype = 'e'
|
|
28
|
-
AND n.nspname = 'public'
|
|
29
|
-
`);
|
|
30
|
-
this.logger.log(`Found ${sourceEnumsResult.rows.length} enum types in source database`);
|
|
31
|
-
for (const enumRow of sourceEnumsResult.rows) {
|
|
32
|
-
const enumName = enumRow.enum_name;
|
|
33
|
-
await this.synchronizeEnumType(enumName);
|
|
34
|
-
}
|
|
35
|
-
this.logger.log('Enum synchronization completed successfully');
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
this.logger.error(`Error during enum synchronization: ${error.message}`, error.stack);
|
|
39
|
-
}
|
|
40
|
-
finally {
|
|
41
|
-
await this.cleanup();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async synchronizeEnumType(enumName) {
|
|
45
|
-
this.logger.log(`Synchronizing enum type: ${enumName}`);
|
|
46
|
-
try {
|
|
47
|
-
const sourceEnumValuesResult = await this.sourcePool.query(`
|
|
48
|
-
SELECT e.enumlabel
|
|
49
|
-
FROM pg_enum e
|
|
50
|
-
JOIN pg_type t ON e.enumtypid = t.oid
|
|
51
|
-
WHERE t.typname = $1
|
|
52
|
-
ORDER BY e.enumsortorder
|
|
53
|
-
`, [enumName]);
|
|
54
|
-
const sourceEnumValues = sourceEnumValuesResult.rows.map(row => row.enumlabel);
|
|
55
|
-
this.logger.log(`Source enum ${enumName} has values: ${sourceEnumValues.join(', ')}`);
|
|
56
|
-
const targetEnumExistsResult = await this.targetPool.query(`
|
|
57
|
-
SELECT 1
|
|
58
|
-
FROM pg_type t
|
|
59
|
-
JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
|
|
60
|
-
WHERE t.typtype = 'e'
|
|
61
|
-
AND t.typname = $1
|
|
62
|
-
AND n.nspname = 'public'
|
|
63
|
-
LIMIT 1
|
|
64
|
-
`, [enumName]);
|
|
65
|
-
if (targetEnumExistsResult.rows.length === 0) {
|
|
66
|
-
await this.createEnumType(enumName, sourceEnumValues);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
await this.updateEnumValues(enumName, sourceEnumValues);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
this.logger.error(`Error synchronizing enum type ${enumName}: ${error.message}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
async createEnumType(enumName, values) {
|
|
77
|
-
this.logger.log(`Creating enum type ${enumName} in target database`);
|
|
78
|
-
try {
|
|
79
|
-
const escapedValues = values.map(value => `'${value.replace(/'/g, "''")}'`).join(', ');
|
|
80
|
-
await this.targetPool.query(`
|
|
81
|
-
CREATE TYPE ${enumName} AS ENUM (${escapedValues})
|
|
82
|
-
`);
|
|
83
|
-
this.logger.log(`Successfully created enum type ${enumName} with values: ${values.join(', ')}`);
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
this.logger.error(`Error creating enum type ${enumName}: ${error.message}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async updateEnumValues(enumName, sourceValues) {
|
|
90
|
-
this.logger.log(`Updating enum type ${enumName} in target database`);
|
|
91
|
-
try {
|
|
92
|
-
const targetEnumValuesResult = await this.targetPool.query(`
|
|
93
|
-
SELECT e.enumlabel
|
|
94
|
-
FROM pg_enum e
|
|
95
|
-
JOIN pg_type t ON e.enumtypid = t.oid
|
|
96
|
-
WHERE t.typname = $1
|
|
97
|
-
ORDER BY e.enumsortorder
|
|
98
|
-
`, [enumName]);
|
|
99
|
-
const targetEnumValues = targetEnumValuesResult.rows.map(row => row.enumlabel);
|
|
100
|
-
this.logger.log(`Target enum ${enumName} has values: ${targetEnumValues.join(', ')}`);
|
|
101
|
-
const missingValues = sourceValues.filter(value => !targetEnumValues.includes(value));
|
|
102
|
-
if (missingValues.length === 0) {
|
|
103
|
-
this.logger.log(`Enum type ${enumName} is already up to date`);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
this.logger.log(`Adding ${missingValues.length} new values to enum ${enumName}: ${missingValues.join(', ')}`);
|
|
107
|
-
for (const value of missingValues) {
|
|
108
|
-
await this.targetPool.query(`
|
|
109
|
-
ALTER TYPE ${enumName} ADD VALUE '${value.replace(/'/g, "''")}'
|
|
110
|
-
`);
|
|
111
|
-
}
|
|
112
|
-
this.logger.log(`Successfully updated enum type ${enumName}`);
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
this.logger.error(`Error updating enum type ${enumName}: ${error.message}`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
async cleanup() {
|
|
119
|
-
this.logger.log('Cleaning up database connections');
|
|
120
|
-
await this.sourcePool.end();
|
|
121
|
-
await this.targetPool.end();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
exports.EnumSynchronizer = EnumSynchronizer;
|
|
125
|
-
if (require.main === module) {
|
|
126
|
-
const run = async () => {
|
|
127
|
-
try {
|
|
128
|
-
const synchronizer = new EnumSynchronizer();
|
|
129
|
-
await synchronizer.synchronizeEnums();
|
|
130
|
-
process.exit(0);
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
console.error('Error:', error.message);
|
|
134
|
-
process.exit(1);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
run();
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=sync-enum-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync-enum-types.js","sourceRoot":"","sources":["../../src/scripts/sync-enum-types.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,iCAAiC;AACjC,2CAAwC;AAExC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAa,gBAAgB;IAK3B,YACmB,YAAoB,OAAO,CAAC,GAAG,CAAC,mBAAmB,EACnD,YAAoB,OAAO,CAAC,GAAG,CAAC,YAAY;QAD5C,cAAS,GAAT,SAAS,CAA0C;QACnD,cAAS,GAAT,SAAS,CAAmC;QAN9C,WAAM,GAAG,IAAI,eAAM,CAAC,kBAAkB,CAAC,CAAC;QAQvD,IAAI,CAAC,UAAU,GAAG,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
private readonly targetUrl;
|
|
4
|
-
private readonly logger;
|
|
5
|
-
private readonly pool;
|
|
6
|
-
private readonly enumMappings;
|
|
7
|
-
private readonly valueNormalizationMap;
|
|
8
|
-
private enumValuesCache;
|
|
9
|
-
constructor(sourceUrl?: string, targetUrl?: string);
|
|
10
|
-
synchronizeEnumValues(): Promise<void>;
|
|
11
|
-
private synchronizeSpecificEnum;
|
|
12
|
-
private enumExists;
|
|
13
|
-
private getEnumValues;
|
|
14
|
-
private addValueToEnum;
|
|
15
|
-
private normalizeEnumValuesInTables;
|
|
16
|
-
private getSchemas;
|
|
17
|
-
private normalizeEnumValuesInSchema;
|
|
18
|
-
private normalizeEnumColumn;
|
|
19
|
-
private getNormalizedEnumValue;
|
|
20
|
-
}
|