@squiz/db-lib 1.2.2 → 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +9 -1
- package/lib/index.js +25 -20
- package/lib/index.js.map +3 -3
- package/package.json +3 -3
- package/src/ConnectionManager.ts +4 -4
- package/src/Migrator.ts +14 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
@@ -3,7 +3,15 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
-
## [1.2.
|
6
|
+
## [1.2.9](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.2...v1.2.9) (2022-11-04)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @squiz/db-lib
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [1.2.2](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1...v1.2.2) (2022-09-26)
|
7
15
|
|
8
16
|
**Note:** Version bump only for package @squiz/db-lib
|
9
17
|
|
package/lib/index.js
CHANGED
@@ -4553,7 +4553,7 @@ var require_has_flag = __commonJS({
|
|
4553
4553
|
var require_supports_colors = __commonJS({
|
4554
4554
|
"../dx-logger-lib/node_modules/@colors/colors/lib/system/supports-colors.js"(exports, module2) {
|
4555
4555
|
"use strict";
|
4556
|
-
var
|
4556
|
+
var os2 = require("os");
|
4557
4557
|
var hasFlag = require_has_flag();
|
4558
4558
|
var env = process.env;
|
4559
4559
|
var forceColor = void 0;
|
@@ -4591,7 +4591,7 @@ var require_supports_colors = __commonJS({
|
|
4591
4591
|
}
|
4592
4592
|
var min = forceColor ? 1 : 0;
|
4593
4593
|
if (process.platform === "win32") {
|
4594
|
-
var osRelease =
|
4594
|
+
var osRelease = os2.release().split(".");
|
4595
4595
|
if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
4596
4596
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
4597
4597
|
}
|
@@ -9930,7 +9930,7 @@ var require_winston_transport = __commonJS({
|
|
9930
9930
|
var require_console = __commonJS({
|
9931
9931
|
"../dx-logger-lib/node_modules/winston/lib/winston/transports/console.js"(exports, module2) {
|
9932
9932
|
"use strict";
|
9933
|
-
var
|
9933
|
+
var os2 = require("os");
|
9934
9934
|
var { LEVEL, MESSAGE } = require_triple_beam();
|
9935
9935
|
var TransportStream = require_winston_transport();
|
9936
9936
|
module2.exports = class Console extends TransportStream {
|
@@ -9939,7 +9939,7 @@ var require_console = __commonJS({
|
|
9939
9939
|
this.name = options.name || "console";
|
9940
9940
|
this.stderrLevels = this._stringArrayToSet(options.stderrLevels);
|
9941
9941
|
this.consoleWarnLevels = this._stringArrayToSet(options.consoleWarnLevels);
|
9942
|
-
this.eol = typeof options.eol === "string" ? options.eol :
|
9942
|
+
this.eol = typeof options.eol === "string" ? options.eol : os2.EOL;
|
9943
9943
|
this.setMaxListeners(30);
|
9944
9944
|
}
|
9945
9945
|
log(info, callback) {
|
@@ -12972,7 +12972,7 @@ var require_file = __commonJS({
|
|
12972
12972
|
var { Stream, PassThrough } = require_readable();
|
12973
12973
|
var TransportStream = require_winston_transport();
|
12974
12974
|
var debug = require_node2()("winston:file");
|
12975
|
-
var
|
12975
|
+
var os2 = require("os");
|
12976
12976
|
var tailFile = require_tail_file();
|
12977
12977
|
module2.exports = class File extends TransportStream {
|
12978
12978
|
constructor(options = {}) {
|
@@ -13005,7 +13005,7 @@ var require_file = __commonJS({
|
|
13005
13005
|
this.rotationFormat = options.rotationFormat || false;
|
13006
13006
|
this.zippedArchive = options.zippedArchive || false;
|
13007
13007
|
this.maxFiles = options.maxFiles || null;
|
13008
|
-
this.eol = typeof options.eol === "string" ? options.eol :
|
13008
|
+
this.eol = typeof options.eol === "string" ? options.eol : os2.EOL;
|
13009
13009
|
this.tailable = options.tailable || false;
|
13010
13010
|
this._size = 0;
|
13011
13011
|
this._pendingSize = 0;
|
@@ -13575,7 +13575,7 @@ var require_stream2 = __commonJS({
|
|
13575
13575
|
"use strict";
|
13576
13576
|
var isStream = require_is_stream();
|
13577
13577
|
var { MESSAGE } = require_triple_beam();
|
13578
|
-
var
|
13578
|
+
var os2 = require("os");
|
13579
13579
|
var TransportStream = require_winston_transport();
|
13580
13580
|
module2.exports = class Stream extends TransportStream {
|
13581
13581
|
constructor(options = {}) {
|
@@ -13586,7 +13586,7 @@ var require_stream2 = __commonJS({
|
|
13586
13586
|
this._stream = options.stream;
|
13587
13587
|
this._stream.setMaxListeners(Infinity);
|
13588
13588
|
this.isObjectMode = options.stream._writableState.objectMode;
|
13589
|
-
this.eol = typeof options.eol === "string" ? options.eol :
|
13589
|
+
this.eol = typeof options.eol === "string" ? options.eol : os2.EOL;
|
13590
13590
|
}
|
13591
13591
|
log(info, callback) {
|
13592
13592
|
setImmediate(() => this.emit("logged", info));
|
@@ -13951,7 +13951,7 @@ var require_exception_stream = __commonJS({
|
|
13951
13951
|
var require_exception_handler = __commonJS({
|
13952
13952
|
"../dx-logger-lib/node_modules/winston/lib/winston/exception-handler.js"(exports, module2) {
|
13953
13953
|
"use strict";
|
13954
|
-
var
|
13954
|
+
var os2 = require("os");
|
13955
13955
|
var asyncForEach = require_forEach();
|
13956
13956
|
var debug = require_node2()("winston:exception");
|
13957
13957
|
var once = require_one_time();
|
@@ -14018,8 +14018,8 @@ var require_exception_handler = __commonJS({
|
|
14018
14018
|
}
|
14019
14019
|
getOsInfo() {
|
14020
14020
|
return {
|
14021
|
-
loadavg:
|
14022
|
-
uptime:
|
14021
|
+
loadavg: os2.loadavg(),
|
14022
|
+
uptime: os2.uptime()
|
14023
14023
|
};
|
14024
14024
|
}
|
14025
14025
|
getTrace(err) {
|
@@ -14098,7 +14098,7 @@ var require_exception_handler = __commonJS({
|
|
14098
14098
|
var require_rejection_handler = __commonJS({
|
14099
14099
|
"../dx-logger-lib/node_modules/winston/lib/winston/rejection-handler.js"(exports, module2) {
|
14100
14100
|
"use strict";
|
14101
|
-
var
|
14101
|
+
var os2 = require("os");
|
14102
14102
|
var asyncForEach = require_forEach();
|
14103
14103
|
var debug = require_node2()("winston:rejection");
|
14104
14104
|
var once = require_one_time();
|
@@ -14167,8 +14167,8 @@ var require_rejection_handler = __commonJS({
|
|
14167
14167
|
}
|
14168
14168
|
getOsInfo() {
|
14169
14169
|
return {
|
14170
|
-
loadavg:
|
14171
|
-
uptime:
|
14170
|
+
loadavg: os2.loadavg(),
|
14171
|
+
uptime: os2.uptime()
|
14172
14172
|
};
|
14173
14173
|
}
|
14174
14174
|
getTrace(err) {
|
@@ -31151,7 +31151,6 @@ var AbstractRepository = class {
|
|
31151
31151
|
|
31152
31152
|
// src/ConnectionManager.ts
|
31153
31153
|
var import_pg = __toESM(require_lib2());
|
31154
|
-
var import_os2 = __toESM(require("os"));
|
31155
31154
|
|
31156
31155
|
// src/Migrator.ts
|
31157
31156
|
var import_promises = __toESM(require("fs/promises"));
|
@@ -31201,6 +31200,15 @@ var Migrator = class {
|
|
31201
31200
|
throw new Error(`${pending[i]} has already run. Are you sure your migrations are in the correct order.`);
|
31202
31201
|
}
|
31203
31202
|
}
|
31203
|
+
for (let i = 0; i < migrationsList.length; i++) {
|
31204
|
+
if (migrationsList[i] !== appliedMigrations[i] && appliedMigrations[i] !== void 0) {
|
31205
|
+
throw new Error(
|
31206
|
+
`Migration #${i + 1} ${migrationsList[i]} on the migration list does not match with the applied migration ${appliedMigrations[i]}. Are you sure your migrations are running in the correct DB? Migration list: [${migrationsList.join(
|
31207
|
+
", "
|
31208
|
+
)}], Applied migrations: [${appliedMigrations.join(", ")}]`
|
31209
|
+
);
|
31210
|
+
}
|
31211
|
+
}
|
31204
31212
|
return pending;
|
31205
31213
|
}
|
31206
31214
|
async getSql(migration) {
|
@@ -31239,7 +31247,7 @@ var Migrator = class {
|
|
31239
31247
|
logger.info("No pending migrations");
|
31240
31248
|
return;
|
31241
31249
|
}
|
31242
|
-
logger.info("Pending migrations:\n "
|
31250
|
+
logger.info("Pending migrations:\n " + pending.join("\n "));
|
31243
31251
|
for (const migration of pending) {
|
31244
31252
|
await this.runMigration(migration);
|
31245
31253
|
}
|
@@ -31281,10 +31289,7 @@ var ConnectionManager = class {
|
|
31281
31289
|
this.pool = new import_pg.Pool({
|
31282
31290
|
...connectionInfo,
|
31283
31291
|
application_name: applicationName,
|
31284
|
-
query_timeout: 5e3
|
31285
|
-
idleTimeoutMillis: 0,
|
31286
|
-
connectionTimeoutMillis: 2e3,
|
31287
|
-
max: import_os2.default.cpus().length * 2
|
31292
|
+
query_timeout: 5e3
|
31288
31293
|
});
|
31289
31294
|
this.repositories = repositoryCreator(this);
|
31290
31295
|
}
|