migraguard 0.10.2 → 0.10.3

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 CHANGED
@@ -520,6 +520,7 @@ var init_dsl = __esm({
520
520
  // src/db-mysql.ts
521
521
  var ADVISORY_LOCK_KEY = "migraguard-apply";
522
522
  var CONNECTION_TIMEOUT_MS = 1e4;
523
+ var SESSION_MAX_EXECUTION_TIME_MS = 3e4;
523
524
  var DDL_LOCK_TIMEOUT_SEC = 5;
524
525
  var CREATE_TABLE_SQL = `
525
526
  CREATE TABLE IF NOT EXISTS schema_migrations (
@@ -563,6 +564,10 @@ var MigraguardDbMysql = class {
563
564
  password: this.config.connection.password,
564
565
  connectTimeout: CONNECTION_TIMEOUT_MS
565
566
  });
567
+ try {
568
+ await this.exec(`SET SESSION max_execution_time = ${SESSION_MAX_EXECUTION_TIME_MS}`);
569
+ } catch {
570
+ }
566
571
  }
567
572
  async close() {
568
573
  await this.connection?.end();
@@ -581,6 +586,10 @@ var MigraguardDbMysql = class {
581
586
  }
582
587
  } finally {
583
588
  await this.exec(`SET SESSION lock_wait_timeout = DEFAULT`);
589
+ try {
590
+ await this.exec(`SET SESSION max_execution_time = ${SESSION_MAX_EXECUTION_TIME_MS}`);
591
+ } catch {
592
+ }
584
593
  }
585
594
  }
586
595
  async tableHasAllColumns() {
@@ -802,6 +811,7 @@ function createDb(config) {
802
811
  }
803
812
  }
804
813
  var CONNECTION_TIMEOUT_MS2 = 1e4;
814
+ var SESSION_STATEMENT_TIMEOUT_MS = 3e4;
805
815
  var DDL_LOCK_TIMEOUT = "5s";
806
816
  var DDL_STATEMENT_TIMEOUT = "10s";
807
817
  var REQUIRED_COLUMNS = ["migration_class", "phase", "group_name", "tag"];
@@ -819,6 +829,7 @@ var MigraguardDb = class {
819
829
  }
820
830
  async connect() {
821
831
  await this.client.connect();
832
+ await this.client.query(`SET statement_timeout = ${SESSION_STATEMENT_TIMEOUT_MS}`);
822
833
  }
823
834
  async close() {
824
835
  await this.client.end();
@@ -832,7 +843,7 @@ var MigraguardDb = class {
832
843
  await this.client.query(ALTER_TABLE_SQL);
833
844
  } finally {
834
845
  await this.client.query("RESET lock_timeout");
835
- await this.client.query("RESET statement_timeout");
846
+ await this.client.query(`SET statement_timeout = ${SESSION_STATEMENT_TIMEOUT_MS}`);
836
847
  }
837
848
  }
838
849
  async tableHasAllColumns() {
@@ -5369,9 +5380,11 @@ async function createPgShadow(conn, dbName) {
5369
5380
  port: conn.port,
5370
5381
  database: "postgres",
5371
5382
  user: conn.user,
5372
- password: conn.password
5383
+ password: conn.password,
5384
+ connectionTimeoutMillis: 1e4
5373
5385
  });
5374
5386
  await client.connect();
5387
+ await client.query("SET statement_timeout = 30000");
5375
5388
  try {
5376
5389
  await client.query(`CREATE DATABASE "${dbName}"`);
5377
5390
  } finally {
@@ -5384,9 +5397,11 @@ async function dropPgShadow(conn, dbName) {
5384
5397
  port: conn.port,
5385
5398
  database: "postgres",
5386
5399
  user: conn.user,
5387
- password: conn.password
5400
+ password: conn.password,
5401
+ connectionTimeoutMillis: 1e4
5388
5402
  });
5389
5403
  await client.connect();
5404
+ await client.query("SET statement_timeout = 30000");
5390
5405
  try {
5391
5406
  await client.query(`DROP DATABASE IF EXISTS "${dbName}"`);
5392
5407
  } finally {
@@ -6608,6 +6623,7 @@ program.command("explain").description("Explain command output in human-readable
6608
6623
  reportFormat: opts.reportFormat
6609
6624
  });
6610
6625
  }));
6611
- program.parse();
6626
+ await program.parseAsync();
6627
+ process.exit(0);
6612
6628
  //# sourceMappingURL=cli.js.map
6613
6629
  //# sourceMappingURL=cli.js.map