@famgia/omnify-cli 2.0.44 → 2.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +41 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +41 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -1
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -1405,6 +1405,16 @@ function getCliVersion() {
|
|
|
1405
1405
|
function hasPluginGenerators(plugins) {
|
|
1406
1406
|
return plugins.some((p) => p.generators && p.generators.length > 0);
|
|
1407
1407
|
}
|
|
1408
|
+
function toTableName(schemaName) {
|
|
1409
|
+
const snake = schemaName.replace(/([A-Z])/g, "_$1").toLowerCase().replace(/^_/, "");
|
|
1410
|
+
if (snake.endsWith("y") && !["ay", "ey", "iy", "oy", "uy"].some((v) => snake.endsWith(v))) {
|
|
1411
|
+
return snake.slice(0, -1) + "ies";
|
|
1412
|
+
}
|
|
1413
|
+
if (snake.endsWith("s") || snake.endsWith("x") || snake.endsWith("ch") || snake.endsWith("sh")) {
|
|
1414
|
+
return snake + "es";
|
|
1415
|
+
}
|
|
1416
|
+
return snake + "s";
|
|
1417
|
+
}
|
|
1408
1418
|
function getExistingMigrationTables(migrationsDir) {
|
|
1409
1419
|
const existingTables = /* @__PURE__ */ new Set();
|
|
1410
1420
|
if (!(0, import_node_fs9.existsSync)(migrationsDir)) {
|
|
@@ -2398,7 +2408,37 @@ async function runGenerate(options) {
|
|
|
2398
2408
|
allMigrationRecords = counts.migrationRecords;
|
|
2399
2409
|
}
|
|
2400
2410
|
logger.step("Updating lock file...");
|
|
2401
|
-
|
|
2411
|
+
const migratedSchemas = /* @__PURE__ */ new Set();
|
|
2412
|
+
for (const record of allMigrationRecords) {
|
|
2413
|
+
for (const schemaName of record.schemas) {
|
|
2414
|
+
migratedSchemas.add(schemaName);
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
const modifiedWithoutMigration = [];
|
|
2418
|
+
for (const change of comparison.changes) {
|
|
2419
|
+
if (change.changeType === "modified") {
|
|
2420
|
+
const hasMigration = migratedSchemas.has(change.schemaName) || // Also check if there's an ALTER migration by table name
|
|
2421
|
+
allMigrationRecords.some(
|
|
2422
|
+
(r) => r.type === "alter" && r.tableName === toTableName(change.schemaName)
|
|
2423
|
+
);
|
|
2424
|
+
if (!hasMigration) {
|
|
2425
|
+
modifiedWithoutMigration.push(change.schemaName);
|
|
2426
|
+
logger.warn(`\u26A0\uFE0F Schema '${change.schemaName}' was modified but no ALTER migration was generated.`);
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
let snapshotsToUpdate = currentSnapshots;
|
|
2431
|
+
if (modifiedWithoutMigration.length > 0 && existingLock && (0, import_omnify_atlas2.isLockFileV2)(existingLock)) {
|
|
2432
|
+
logger.warn("Keeping old state for schemas without migrations to ensure they are detected on next run.");
|
|
2433
|
+
snapshotsToUpdate = { ...currentSnapshots };
|
|
2434
|
+
for (const schemaName of modifiedWithoutMigration) {
|
|
2435
|
+
if (existingLock.schemas[schemaName]) {
|
|
2436
|
+
snapshotsToUpdate[schemaName] = existingLock.schemas[schemaName];
|
|
2437
|
+
logger.debug(` Keeping old state for: ${schemaName}`);
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
let newLockFile = (0, import_omnify_atlas2.updateLockFile)(existingLock, snapshotsToUpdate, config.database.driver);
|
|
2402
2442
|
if (allMigrationRecords.length > 0) {
|
|
2403
2443
|
logger.debug(`Adding ${allMigrationRecords.length} migration(s) to lock file...`);
|
|
2404
2444
|
for (const record of allMigrationRecords) {
|