@dbcube/schema-builder 5.1.6 → 5.1.7

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/index.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Config, Engine } from '@dbcube/core';
2
+
1
3
  /**
2
4
  * Main class to handle MySQL database connections and queries.
3
5
  * Implements the Singleton pattern to ensure a single instance of the connection pool.
@@ -28,7 +30,9 @@ export declare class Schema {
28
30
  refreshTables(): Promise<any>;
29
31
  freshTables(): Promise<any>;
30
32
  executeSeeders(filterName?: string): Promise<any>;
31
- executeAlters(): Promise<any>;
33
+ executeAlters(filterFiles?: string[] | null, options?: {
34
+ dryRun?: boolean;
35
+ }): Promise<any>;
32
36
  executeTriggers(): Promise<any>;
33
37
  }
34
38
  export interface ProcessError {
@@ -136,6 +140,8 @@ export declare class DependencyResolver {
136
140
  }
137
141
 
138
142
  export {
143
+ Config,
144
+ Engine,
139
145
  Schema as default,
140
146
  };
141
147
 
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Config, Engine } from '@dbcube/core';
2
+
1
3
  /**
2
4
  * Main class to handle MySQL database connections and queries.
3
5
  * Implements the Singleton pattern to ensure a single instance of the connection pool.
@@ -28,7 +30,9 @@ export declare class Schema {
28
30
  refreshTables(): Promise<any>;
29
31
  freshTables(): Promise<any>;
30
32
  executeSeeders(filterName?: string): Promise<any>;
31
- executeAlters(): Promise<any>;
33
+ executeAlters(filterFiles?: string[] | null, options?: {
34
+ dryRun?: boolean;
35
+ }): Promise<any>;
32
36
  executeTriggers(): Promise<any>;
33
37
  }
34
38
  export interface ProcessError {
@@ -136,6 +140,8 @@ export declare class DependencyResolver {
136
140
  }
137
141
 
138
142
  export {
143
+ Config,
144
+ Engine,
139
145
  Schema as default,
140
146
  };
141
147
 
package/dist/index.js CHANGED
@@ -1393,13 +1393,18 @@ var Schema = class {
1393
1393
  UIUtils.showOperationSummary(summary);
1394
1394
  return totalSeedersProcessed > 0 ? { processed: totalSeedersProcessed, success: successCount, errors: errorCount } : null;
1395
1395
  }
1396
- async executeAlters() {
1396
+ async executeAlters(filterFiles, options = {}) {
1397
1397
  const startTime = Date.now();
1398
1398
  const cubesDir = path4.join(process.cwd(), "dbcube");
1399
+ const dryRun = options.dryRun === true;
1399
1400
  if (!fs5.existsSync(cubesDir)) {
1400
1401
  throw new Error("\u274C The cubes folder does not exist");
1401
1402
  }
1402
- const cubeFiles = FileUtils_default.getCubeFilesRecursively("dbcube", ".alter.cube");
1403
+ let cubeFiles = FileUtils_default.getCubeFilesRecursively("dbcube", ".alter.cube");
1404
+ if (filterFiles && filterFiles.length > 0) {
1405
+ const wanted = new Set(filterFiles.map((f) => path4.basename(f)));
1406
+ cubeFiles = cubeFiles.filter((f) => wanted.has(path4.basename(f)));
1407
+ }
1403
1408
  if (cubeFiles.length === 0) {
1404
1409
  throw new Error("\u274C There are no .alter.cube files to execute");
1405
1410
  }
@@ -1454,6 +1459,22 @@ var Schema = class {
1454
1459
  }
1455
1460
  delete queries.data.database_type;
1456
1461
  const parseJsonQueries = JSON.stringify(queries.data);
1462
+ if (dryRun) {
1463
+ console.log(`
1464
+ ${chalk2.cyan("\u2500\u2500 dry-run \u2500\u2500")} ${chalk2.bold(alterName)}`);
1465
+ const allQueries = [
1466
+ ...queries.data.regular_queries ?? [],
1467
+ ...queries.data.special_queries ?? []
1468
+ ];
1469
+ for (const q of allQueries) {
1470
+ console.log(` ${chalk2.gray("SQL>")} ${q}`);
1471
+ }
1472
+ UIUtils.showItemSuccess(alterName + " (dry-run)");
1473
+ successCount++;
1474
+ processedAlters.push(alterName);
1475
+ totalAltersProcessed++;
1476
+ continue;
1477
+ }
1457
1478
  const response = await this.engine.run("schema_engine", [
1458
1479
  "--action",
1459
1480
  "execute",
@@ -1612,10 +1633,13 @@ ${chalk2.red("\u{1F6AB}")} ${chalk2.bold.red("ERRORS FOUND")}`);
1612
1633
  }
1613
1634
 
1614
1635
  // src/index.ts
1636
+ import { Engine as Engine2, Config } from "@dbcube/core";
1615
1637
  var index_default = Schema;
1616
1638
  export {
1639
+ Config,
1617
1640
  CubeValidator,
1618
1641
  DependencyResolver,
1642
+ Engine2 as Engine,
1619
1643
  Schema,
1620
1644
  UIUtils,
1621
1645
  index_default as default