rake-db 2.37.13 → 2.37.14

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.ts CHANGED
@@ -1777,6 +1777,11 @@ interface MigrateConfigBase extends QueryLogOptions {
1777
1777
  migrationsTable?: string;
1778
1778
  transaction?: 'single' | 'per-migration';
1779
1779
  transactionSearchPath?: SearchPath;
1780
+ /**
1781
+ * Advisory lock key used while migrating or rolling back.
1782
+ * Defaults to rake-db's fixed lock key.
1783
+ */
1784
+ migrationLockKey?: bigint;
1780
1785
  forceDefaultExports?: boolean;
1781
1786
  beforeChange?: ChangeCallback$1;
1782
1787
  afterChange?: ChangeCallback$1;
@@ -1899,6 +1904,11 @@ interface RakeDbCliConfigInputBase<SchemaConfig extends ColumnSchemaConfig, CT =
1899
1904
  };
1900
1905
  noPrimaryKey?: NoPrimaryKeyOption;
1901
1906
  transactionSearchPath?: SearchPath;
1907
+ /**
1908
+ * Advisory lock key used while migrating or rolling back.
1909
+ * Defaults to rake-db's fixed lock key.
1910
+ */
1911
+ migrationLockKey?: bigint;
1902
1912
  /**
1903
1913
  * Throw if a migration doesn't have a default export.
1904
1914
  * This is needed when in your setup you're importing migration files first and execute them later,
@@ -1998,6 +2008,7 @@ interface RakeDbConfig<ColumnTypes = unknown> extends QueryLogOptions {
1998
2008
  afterRollback?: MigrationCallback;
1999
2009
  migrationId: RakeDbMigrationId;
2000
2010
  transactionSearchPath?: SearchPath;
2011
+ migrationLockKey?: bigint;
2001
2012
  forceDefaultExports?: boolean;
2002
2013
  afterChangeCommit?: ChangeCommitCallback;
2003
2014
  basePath: string;
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ let node_url = require("node:url");
26
26
  let pqb = require("pqb");
27
27
  let node_fs_promises = require("node:fs/promises");
28
28
  node_fs_promises = __toESM(node_fs_promises);
29
- const RAKE_DB_LOCK_KEY = "8582141715823621641";
29
+ const RAKE_DB_LOCK_KEY = 8582141715823621641n;
30
30
  const getFirstWordAndRest = (input) => {
31
31
  const i = input.search(/(?=[A-Z])|[-_ ]/);
32
32
  if (i !== -1) {
@@ -88,7 +88,7 @@ const transaction = (adapter, config, fn) => {
88
88
  const searchPath = config.transactionSearchPath;
89
89
  return adapter.transaction(void 0, searchPath ? { setConfig: { search_path: typeof searchPath === "function" ? searchPath() : searchPath } } : void 0, fn);
90
90
  };
91
- const queryLock = (trx) => trx.query(`SELECT pg_advisory_xact_lock('${RAKE_DB_LOCK_KEY}')`);
91
+ const queryLock = (trx, key = RAKE_DB_LOCK_KEY) => trx.query(`SELECT pg_advisory_xact_lock('${key}')`);
92
92
  const getCliParam = (args, name) => {
93
93
  if (args) {
94
94
  const key = "--" + name;
@@ -3482,7 +3482,7 @@ const migrateOrRollback = async (trx, config, set, versions, count, up, redo, fo
3482
3482
  set.migrations.reverse();
3483
3483
  }
3484
3484
  }
3485
- if (!skipLock) await queryLock(trx);
3485
+ if (!skipLock) await queryLock(trx, config.migrationLockKey);
3486
3486
  let db;
3487
3487
  const beforeMigrate = config[up ? "beforeMigrate" : "beforeRollback"];
3488
3488
  if (beforeMigrate || config.beforeChange) {