@proteinjs/db-driver-knex 1.1.16 → 1.1.18
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/CHANGELOG.md +11 -0
- package/dist/generated/index.d.ts +1 -0
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +2 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/src/KnexDriver.d.ts.map +1 -1
- package/dist/src/KnexDriver.js +4 -4
- package/dist/src/KnexDriver.js.map +1 -1
- package/dist/src/KnexSchemaOperations.d.ts.map +1 -1
- package/dist/src/KnexSchemaOperations.js +21 -15
- package/dist/src/KnexSchemaOperations.js.map +1 -1
- package/generated/index.ts +9 -5
- package/package.json +8 -8
- package/src/KnexDriver.ts +4 -4
- package/src/KnexSchemaOperations.ts +21 -15
- package/LICENSE +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.1.17](https://github.com/proteinjs/db/compare/@proteinjs/db-driver-knex@1.1.16...@proteinjs/db-driver-knex@1.1.17) (2024-08-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* refactored to implement new @proteinjs/logger/Logger api ([66578f2](https://github.com/proteinjs/db/commit/66578f267d9293c0d5703c63e53d8edf68325f52))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.1.16](https://github.com/proteinjs/db/compare/@proteinjs/db-driver-knex@1.1.15...@proteinjs/db-driver-knex@1.1.16) (2024-08-11)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,eAAe,CAAC;AACvB,OAAO,qBAAqB,CAAC;AAC7B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,iBAAiB,CAAC;AACzB,OAAO,MAAM,CAAC;AACd,OAAO,QAAQ,CAAC;AAChB,OAAO,OAAO,CAAC;AACf,OAAO,MAAM,CAAC;AAyBd,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,eAAe,CAAC;AACvB,OAAO,qBAAqB,CAAC;AAC7B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,iBAAiB,CAAC;AACzB,OAAO,MAAM,CAAC;AACd,OAAO,QAAQ,CAAC;AAChB,OAAO,OAAO,CAAC;AACf,OAAO,MAAM,CAAC;AAyBd,cAAc,UAAU,CAAC"}
|
package/dist/generated/index.js
CHANGED
|
@@ -17,6 +17,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
require("@proteinjs/db");
|
|
19
19
|
require("@proteinjs/db-query");
|
|
20
|
+
require("@proteinjs/logger");
|
|
20
21
|
require("@proteinjs/reflection");
|
|
21
22
|
require("@proteinjs/util");
|
|
22
23
|
require("knex");
|
|
@@ -24,7 +25,7 @@ require("moment");
|
|
|
24
25
|
require("mysql");
|
|
25
26
|
require("uuid");
|
|
26
27
|
/** Generate Source Graph */
|
|
27
|
-
var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/db-driver-knex/KnexDriver\",\"value\":{\"packageName\":\"@proteinjs/db-driver-knex\",\"name\":\"KnexDriver\",\"filePath\":\"/
|
|
28
|
+
var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/db-driver-knex/KnexDriver\",\"value\":{\"packageName\":\"@proteinjs/db-driver-knex\",\"name\":\"KnexDriver\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/db/packages/drivers/knex/src/KnexDriver.ts\",\"qualifiedName\":\"@proteinjs/db-driver-knex/KnexDriver\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"KNEX\",\"type\":{\"packageName\":\"\",\"name\":\"knex\",\"filePath\":null,\"qualifiedName\":\"/knex\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":true,\"visibility\":\"private\"},{\"name\":\"logger\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"},{\"name\":\"config\",\"type\":{\"packageName\":\"@proteinjs/db-driver-knex\",\"name\":\"KnexConfig\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db-driver-knex/KnexConfig\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"},{\"name\":\"knexConfig\",\"type\":{\"packageName\":\"\",\"name\":\"any\",\"filePath\":null,\"qualifiedName\":\"/any\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"},{\"name\":\"getTable\",\"type\":{\"packageName\":\"\",\"name\":\"((name: string) => Table<any>) | undefined\",\"filePath\":null,\"qualifiedName\":\"/((name: string) => Table<any>) | undefined\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[{\"name\":\"getKnex\",\"returnType\":{\"packageName\":\"\",\"name\":\"knex\",\"filePath\":null,\"qualifiedName\":\"/knex\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"getDbName\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"createDbIfNotExists\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<void>\",\"filePath\":null,\"qualifiedName\":\"/Promise<void>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"dbExists\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<boolean>\",\"filePath\":null,\"qualifiedName\":\"/Promise<boolean>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[{\"name\":\"databaseName\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"start\",\"returnType\":null,\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"stop\",\"returnType\":null,\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"setMaxAllowedPacketSize\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<void>\",\"filePath\":null,\"qualifiedName\":\"/Promise<void>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[]},{\"name\":\"getTableManager\",\"returnType\":{\"packageName\":\"@proteinjs/db\",\"name\":\"TableManager\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db/TableManager\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"handleCaseSensitivity\",\"returnType\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"tableName\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"columnName\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"caseSensitive\",\"type\":{\"packageName\":\"\",\"name\":\"boolean\",\"filePath\":null,\"qualifiedName\":\"/boolean\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"runQuery\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<SerializedRecord[]>\",\"filePath\":null,\"qualifiedName\":\"/Promise<SerializedRecord[]>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"generateStatement\",\"type\":{\"packageName\":\"\",\"name\":\"(config: DbDriverQueryStatementConfig) => Statement\",\"filePath\":null,\"qualifiedName\":\"/(config: DbDriverQueryStatementConfig) => Statement\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"runDml\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<number>\",\"filePath\":null,\"qualifiedName\":\"/Promise<number>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"generateStatement\",\"type\":{\"packageName\":\"\",\"name\":\"(config: DbDriverDmlStatementConfig) => Statement\",\"filePath\":null,\"qualifiedName\":\"/(config: DbDriverDmlStatementConfig) => Statement\",\"typeParameters\":null,\"directParents\":null}}]}],\"typeParameters\":[],\"directParentInterfaces\":[{\"packageName\":\"@proteinjs/db\",\"name\":\"DbDriver\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db/DbDriver\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"directParentClasses\":[],\"sourceType\":2}},{\"v\":\"@proteinjs/db/DbDriver\"},{\"v\":\"@proteinjs/db-driver-knex/KnexSchemaOperations\",\"value\":{\"packageName\":\"@proteinjs/db-driver-knex\",\"name\":\"KnexSchemaOperations\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/db/packages/drivers/knex/src/KnexSchemaOperations.ts\",\"qualifiedName\":\"@proteinjs/db-driver-knex/KnexSchemaOperations\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"logger\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"},{\"name\":\"knexDriver\",\"type\":{\"packageName\":\"@proteinjs/db-driver-knex\",\"name\":\"KnexDriver\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db-driver-knex/KnexDriver\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"}],\"methods\":[{\"name\":\"createTable\",\"returnType\":null,\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"table\",\"type\":{\"packageName\":\"\",\"name\":\"Table<any>\",\"filePath\":null,\"qualifiedName\":\"/Table<any>\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"alterTable\",\"returnType\":null,\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"table\",\"type\":{\"packageName\":\"\",\"name\":\"Table<any>\",\"filePath\":null,\"qualifiedName\":\"/Table<any>\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"tableChanges\",\"type\":{\"packageName\":\"@proteinjs/db\",\"name\":\"TableChanges\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db/TableChanges\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"createColumn\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[{\"name\":\"column\",\"type\":{\"packageName\":\"\",\"name\":\"Column<any, any>\",\"filePath\":null,\"qualifiedName\":\"/Column<any, any>\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"table\",\"type\":{\"packageName\":\"\",\"name\":\"Table<any>\",\"filePath\":null,\"qualifiedName\":\"/Table<any>\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"tableBuilder\",\"type\":{\"packageName\":\"\",\"name\":\"knex.TableBuilder\",\"filePath\":null,\"qualifiedName\":\"/knex.TableBuilder\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"tableChanges\",\"type\":{\"packageName\":\"@proteinjs/db\",\"name\":\"TableChanges\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db/TableChanges\",\"typeParameters\":null,\"directParents\":null}}]}],\"typeParameters\":[],\"directParentInterfaces\":[{\"packageName\":\"@proteinjs/db\",\"name\":\"SchemaOperations\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db/SchemaOperations\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"directParentClasses\":[],\"sourceType\":2}},{\"v\":\"@proteinjs/db/SchemaOperations\"}],\"edges\":[{\"v\":\"@proteinjs/db-driver-knex/KnexDriver\",\"w\":\"@proteinjs/db/DbDriver\",\"value\":\"implements interface\"},{\"v\":\"@proteinjs/db-driver-knex/KnexSchemaOperations\",\"w\":\"@proteinjs/db/SchemaOperations\",\"value\":\"implements interface\"}]}";
|
|
28
29
|
/** Generate Source Links */
|
|
29
30
|
var KnexDriver_1 = require("../src/KnexDriver");
|
|
30
31
|
var KnexSchemaOperations_1 = require("../src/KnexSchemaOperations");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,yBAAuB;AACvB,+BAA6B;AAC7B,iCAA+B;AAC/B,2BAAyB;AACzB,gBAAc;AACd,kBAAgB;AAChB,iBAAe;AACf,gBAAc;AAGd,4BAA4B;AAE5B,IAAM,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,yBAAuB;AACvB,+BAA6B;AAC7B,6BAA2B;AAC3B,iCAA+B;AAC/B,2BAAyB;AACzB,gBAAc;AACd,kBAAgB;AAChB,iBAAe;AACf,gBAAc;AAGd,4BAA4B;AAE5B,IAAM,WAAW,GAAG,2hTAA2hT,CAAC;AAGhjT,4BAA4B;AAE5B,gDAA+C;AAC/C,oEAAmE;AAEnE,IAAM,WAAW,GAAG;IACnB,sCAAsC,EAAE,uBAAU;IAClD,gDAAgD,EAAE,2CAAoB;CACtE,CAAC;AAGF,kCAAkC;AAElC,oDAAyD;AACzD,6BAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAGjD,2CAAyB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnexDriver.d.ts","sourceRoot":"","sources":["../../src/KnexDriver.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EACL,QAAQ,EACR,4BAA4B,EAC5B,0BAA0B,EAC1B,gBAAgB,EAChB,KAAK,EACL,YAAY,EAEb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIhD,qBAAa,UAAW,YAAW,QAAQ;IACzC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAO;IAC1B,O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}
|
package/dist/src/KnexDriver.js
CHANGED
|
@@ -42,12 +42,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.KnexDriver = void 0;
|
|
43
43
|
var knex_1 = __importDefault(require("knex"));
|
|
44
44
|
var db_1 = require("@proteinjs/db");
|
|
45
|
-
var
|
|
45
|
+
var logger_1 = require("@proteinjs/logger");
|
|
46
46
|
var KnexSchemaOperations_1 = require("./KnexSchemaOperations");
|
|
47
47
|
var KnexColumnTypeFactory_1 = require("./KnexColumnTypeFactory");
|
|
48
48
|
var KnexDriver = /** @class */ (function () {
|
|
49
49
|
function KnexDriver(config, getTable) {
|
|
50
|
-
this.logger = new
|
|
50
|
+
this.logger = new logger_1.Logger({ name: this.constructor.name });
|
|
51
51
|
this.config = config;
|
|
52
52
|
this.knexConfig = {
|
|
53
53
|
client: 'mysql',
|
|
@@ -139,7 +139,7 @@ var KnexDriver = /** @class */ (function () {
|
|
|
139
139
|
case 2:
|
|
140
140
|
_a.sent();
|
|
141
141
|
KnexDriver.KNEX = (0, knex_1.default)(this.knexConfig);
|
|
142
|
-
this.logger.info('Set global max_allowed_packet size to 1gb');
|
|
142
|
+
this.logger.info({ message: 'Set global max_allowed_packet size to 1gb' });
|
|
143
143
|
return [2 /*return*/];
|
|
144
144
|
}
|
|
145
145
|
});
|
|
@@ -189,7 +189,7 @@ var KnexDriver = /** @class */ (function () {
|
|
|
189
189
|
case 2: return [2 /*return*/, (_b.sent())[0]]; // returns 2 arrays, first is records, second is metadata per record
|
|
190
190
|
case 3:
|
|
191
191
|
error_1 = _b.sent();
|
|
192
|
-
this.logger.error("Failed when executing
|
|
192
|
+
this.logger.error({ message: "Failed when executing sql", obj: { sql: sql }, error: error_1 });
|
|
193
193
|
throw error_1;
|
|
194
194
|
case 4: return [2 /*return*/];
|
|
195
195
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnexDriver.js","sourceRoot":"","sources":["../../src/KnexDriver.ts"],"names":[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,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,MAAa,CAAC,EAAA;4BAApD,sBAAO,CAAC,SAA4C,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,oEAAoE;;;wBAE9H,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,2BAA2B,EAAE,GAAG,EAAE,EAAE,GAAG,KAAA,EAAE,EAAE,KAAK,SAAA,EAAE,CAAC,CAAC;wBACjF,MAAM,OAAK,CAAC;;;;;KAEf;IAEK,2BAAM,GAAZ,UAAa,iBAAoE;;;;;4BACrD,qBAAM,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAA;;wBAAxD,YAAY,GAAK,CAAC,SAAsC,CAAQ,aAApD;wBACpB,sBAAO,YAAY,EAAC;;;;KACrB;IACH,iBAAC;AAAD,CAAC,AArHD,IAqHC;AArHY,gCAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnexSchemaOperations.d.ts","sourceRoot":"","sources":["../../src/KnexSchemaOperations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,qBAAa,oBAAqB,YAAW,gBAAgB;IAG/C,OAAO,CAAC,UAAU;IAF9B,OAAO,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"KnexSchemaOperations.d.ts","sourceRoot":"","sources":["../../src/KnexSchemaOperations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,qBAAa,oBAAqB,YAAW,gBAAgB;IAG/C,OAAO,CAAC,UAAU;IAF9B,OAAO,CAAC,MAAM,CAA+C;gBAEzC,UAAU,EAAE,UAAU;IAEpC,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC;IAyC7B,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,YAAY;IAkE9D,OAAO,CAAC,YAAY;CAwCrB"}
|
|
@@ -37,12 +37,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.KnexSchemaOperations = void 0;
|
|
40
|
-
var
|
|
40
|
+
var logger_1 = require("@proteinjs/logger");
|
|
41
41
|
var getColumnFactory_1 = require("./getColumnFactory");
|
|
42
42
|
var KnexSchemaOperations = /** @class */ (function () {
|
|
43
43
|
function KnexSchemaOperations(knexDriver) {
|
|
44
44
|
this.knexDriver = knexDriver;
|
|
45
|
-
this.logger = new
|
|
45
|
+
this.logger = new logger_1.Logger({ name: this.constructor.name });
|
|
46
46
|
}
|
|
47
47
|
KnexSchemaOperations.prototype.createTable = function (table) {
|
|
48
48
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -62,16 +62,16 @@ var KnexSchemaOperations = /** @class */ (function () {
|
|
|
62
62
|
for (var columnPropertyName in table.columns) {
|
|
63
63
|
var column = table.columns[columnPropertyName];
|
|
64
64
|
_this.createColumn(column, table, tableBuilder);
|
|
65
|
-
_this.logger.info("[".concat(table.name, "] Creating column: ").concat(column.name));
|
|
65
|
+
_this.logger.info({ message: "[".concat(table.name, "] Creating column: ").concat(column.name) });
|
|
66
66
|
}
|
|
67
67
|
tableBuilder.primary(['id']);
|
|
68
|
-
_this.logger.info("[".concat(table.name, "] Creating primary key: id"));
|
|
68
|
+
_this.logger.info({ message: "[".concat(table.name, "] Creating primary key: id") });
|
|
69
69
|
if (table.indexes) {
|
|
70
70
|
for (var _i = 0, _a = table.indexes; _i < _a.length; _i++) {
|
|
71
71
|
var index = _a[_i];
|
|
72
72
|
var columnNames = index.columns.map(function (columnPropertyName) { return table.columns[columnPropertyName].name; });
|
|
73
73
|
tableBuilder.index(columnNames, index.name);
|
|
74
|
-
_this.logger.info("[".concat(table.name, "] Creating index: ").concat(columnNames));
|
|
74
|
+
_this.logger.info({ message: "[".concat(table.name, "] Creating index: ").concat(columnNames) });
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
})
|
|
@@ -106,28 +106,30 @@ var KnexSchemaOperations = /** @class */ (function () {
|
|
|
106
106
|
for (var _i = 0, _a = tableChanges.columnsToCreate; _i < _a.length; _i++) {
|
|
107
107
|
var columnPropertyName = _a[_i];
|
|
108
108
|
var column = table.columns[columnPropertyName];
|
|
109
|
-
_this.logger.info("[".concat(table.name, "] Creating column: ").concat(column.name));
|
|
109
|
+
_this.logger.info({ message: "[".concat(table.name, "] Creating column: ").concat(column.name) });
|
|
110
110
|
_this.createColumn(column, table, tableBuilder, tableChanges);
|
|
111
111
|
}
|
|
112
112
|
for (var _b = 0, _c = tableChanges.columnsWithUniqueConstraintsToDrop; _b < _c.length; _b++) {
|
|
113
113
|
var column = _c[_b];
|
|
114
114
|
tableBuilder.dropUnique([column]);
|
|
115
|
-
_this.logger.info("[".concat(table.name, ".").concat(column, "] Dropping unique constraint"));
|
|
115
|
+
_this.logger.info({ message: "[".concat(table.name, ".").concat(column, "] Dropping unique constraint") });
|
|
116
116
|
}
|
|
117
117
|
for (var _d = 0, _e = tableChanges.columnsWithForeignKeysToDrop; _d < _e.length; _d++) {
|
|
118
118
|
var column = _e[_d];
|
|
119
119
|
tableBuilder.dropForeign([column]);
|
|
120
|
-
_this.logger.info("[".concat(table.name, ".").concat(column, "] Dropping foreign key"));
|
|
120
|
+
_this.logger.info({ message: "[".concat(table.name, ".").concat(column, "] Dropping foreign key") });
|
|
121
121
|
}
|
|
122
122
|
for (var _f = 0, _g = tableChanges.indexesToDrop; _f < _g.length; _f++) {
|
|
123
123
|
var index = _g[_f];
|
|
124
124
|
tableBuilder.dropIndex(index.columns);
|
|
125
|
-
_this.logger.info("[".concat(table.name, "] Dropping index: ").concat(JSON.stringify(index)));
|
|
125
|
+
_this.logger.info({ message: "[".concat(table.name, "] Dropping index: ").concat(JSON.stringify(index)) });
|
|
126
126
|
}
|
|
127
127
|
for (var _h = 0, _j = tableChanges.columnsToAlter; _h < _j.length; _h++) {
|
|
128
128
|
var columnPropertyName = _j[_h];
|
|
129
129
|
var column = table.columns[columnPropertyName];
|
|
130
|
-
_this.logger.info(
|
|
130
|
+
_this.logger.info({
|
|
131
|
+
message: "[".concat(table.name, ".").concat(column.name, "] Altering column type to: ").concat(column.constructor.name),
|
|
132
|
+
});
|
|
131
133
|
_this.createColumn(column, table, tableBuilder, tableChanges).alter();
|
|
132
134
|
}
|
|
133
135
|
for (var _k = 0, _l = tableChanges.columnsToRename; _k < _l.length; _k++) {
|
|
@@ -137,12 +139,12 @@ var KnexSchemaOperations = /** @class */ (function () {
|
|
|
137
139
|
continue;
|
|
138
140
|
}
|
|
139
141
|
tableBuilder.renameColumn(column.oldName, column.name);
|
|
140
|
-
_this.logger.info("[".concat(table.name, "] Renaming column: ").concat(column.oldName, " -> ").concat(column.name));
|
|
142
|
+
_this.logger.info({ message: "[".concat(table.name, "] Renaming column: ").concat(column.oldName, " -> ").concat(column.name) });
|
|
141
143
|
}
|
|
142
144
|
for (var _m = 0, _o = tableChanges.indexesToCreate; _m < _o.length; _m++) {
|
|
143
145
|
var index = _o[_m];
|
|
144
146
|
tableBuilder.index(index.columns);
|
|
145
|
-
_this.logger.info("[".concat(table.name, "] Creating index:
|
|
147
|
+
_this.logger.info({ message: "[".concat(table.name, "] Creating index:"), obj: { index: index } });
|
|
146
148
|
}
|
|
147
149
|
})
|
|
148
150
|
.catch(function (reason) {
|
|
@@ -165,12 +167,14 @@ var KnexSchemaOperations = /** @class */ (function () {
|
|
|
165
167
|
if (((_b = (_a = column.options) === null || _a === void 0 ? void 0 : _a.unique) === null || _b === void 0 ? void 0 : _b.unique) &&
|
|
166
168
|
(!tableChanges || tableChanges.columnsWithUniqueConstraintsToCreate.includes(column.name))) {
|
|
167
169
|
columnBuilder.unique(column.options.unique.indexName);
|
|
168
|
-
this.logger.info("[".concat(table.name, ".").concat(column.name, "] Adding unique constraint"));
|
|
170
|
+
this.logger.info({ message: "[".concat(table.name, ".").concat(column.name, "] Adding unique constraint") });
|
|
169
171
|
}
|
|
170
172
|
if (((_c = column.options) === null || _c === void 0 ? void 0 : _c.references) &&
|
|
171
173
|
(!tableChanges || tableChanges.columnsWithForeignKeysToCreate.includes(column.name))) {
|
|
172
174
|
columnBuilder.references('id').inTable("".concat(this.knexDriver.getDbName(), ".").concat(column.options.references.table));
|
|
173
|
-
this.logger.info(
|
|
175
|
+
this.logger.info({
|
|
176
|
+
message: "[".concat(table.name, ".").concat(column.name, "] Adding foreign key -> ").concat(column.options.references.table, ".id"),
|
|
177
|
+
});
|
|
174
178
|
}
|
|
175
179
|
if (typeof ((_d = column.options) === null || _d === void 0 ? void 0 : _d.nullable) !== 'undefined') {
|
|
176
180
|
if ((_e = column.options) === null || _e === void 0 ? void 0 : _e.nullable) {
|
|
@@ -179,7 +183,9 @@ var KnexSchemaOperations = /** @class */ (function () {
|
|
|
179
183
|
else {
|
|
180
184
|
columnBuilder.notNullable();
|
|
181
185
|
}
|
|
182
|
-
this.logger.info(
|
|
186
|
+
this.logger.info({
|
|
187
|
+
message: "[".concat(table.name, ".").concat(column.name, "] Adding constraint nullable: ").concat((_f = column.options) === null || _f === void 0 ? void 0 : _f.nullable),
|
|
188
|
+
});
|
|
183
189
|
}
|
|
184
190
|
return columnBuilder;
|
|
185
191
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnexSchemaOperations.js","sourceRoot":"","sources":["../../src/KnexSchemaOperations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"KnexSchemaOperations.js","sourceRoot":"","sources":["../../src/KnexSchemaOperations.ts"],"names":[],"mappings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M,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAE,CAAC,CAAC;YAC5G,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;gBACf,OAAO,EAAE,WAAI,KAAK,CAAC,IAAI,cAAI,MAAM,CAAC,IAAI,qCAA2B,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,QAAK;aACtG,CAAC,CAAC;SACJ;QAED,IAAI,OAAO,CAAA,MAAA,MAAM,CAAC,OAAO,0CAAE,QAAQ,CAAA,KAAK,WAAW,EAAE;YACnD,IAAI,MAAA,MAAM,CAAC,OAAO,0CAAE,QAAQ,EAAE;gBAC5B,aAAa,CAAC,QAAQ,EAAE,CAAC;aAC1B;iBAAM;gBACL,aAAa,CAAC,WAAW,EAAE,CAAC;aAC7B;YAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;gBACf,OAAO,EAAE,WAAI,KAAK,CAAC,IAAI,cAAI,MAAM,CAAC,IAAI,2CAAiC,MAAA,MAAM,CAAC,OAAO,0CAAE,QAAQ,CAAE;aAClG,CAAC,CAAC;SACJ;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;IACH,2BAAC;AAAD,CAAC,AAxJD,IAwJC;AAxJY,oDAAoB"}
|
package/generated/index.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import '@proteinjs/db';
|
|
4
4
|
import '@proteinjs/db-query';
|
|
5
|
+
import '@proteinjs/logger';
|
|
5
6
|
import '@proteinjs/reflection';
|
|
6
7
|
import '@proteinjs/util';
|
|
7
8
|
import 'knex';
|
|
@@ -9,10 +10,11 @@ import 'moment';
|
|
|
9
10
|
import 'mysql';
|
|
10
11
|
import 'uuid';
|
|
11
12
|
|
|
13
|
+
|
|
12
14
|
/** Generate Source Graph */
|
|
13
15
|
|
|
14
|
-
const sourceGraph =
|
|
15
|
-
|
|
16
|
+
const sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/db-driver-knex/KnexDriver\",\"value\":{\"packageName\":\"@proteinjs/db-driver-knex\",\"name\":\"KnexDriver\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/db/packages/drivers/knex/src/KnexDriver.ts\",\"qualifiedName\":\"@proteinjs/db-driver-knex/KnexDriver\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"KNEX\",\"type\":{\"packageName\":\"\",\"name\":\"knex\",\"filePath\":null,\"qualifiedName\":\"/knex\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":true,\"visibility\":\"private\"},{\"name\":\"logger\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"},{\"name\":\"config\",\"type\":{\"packageName\":\"@proteinjs/db-driver-knex\",\"name\":\"KnexConfig\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db-driver-knex/KnexConfig\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"},{\"name\":\"knexConfig\",\"type\":{\"packageName\":\"\",\"name\":\"any\",\"filePath\":null,\"qualifiedName\":\"/any\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"},{\"name\":\"getTable\",\"type\":{\"packageName\":\"\",\"name\":\"((name: string) => Table<any>) | undefined\",\"filePath\":null,\"qualifiedName\":\"/((name: string) => Table<any>) | undefined\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[{\"name\":\"getKnex\",\"returnType\":{\"packageName\":\"\",\"name\":\"knex\",\"filePath\":null,\"qualifiedName\":\"/knex\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"getDbName\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"createDbIfNotExists\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<void>\",\"filePath\":null,\"qualifiedName\":\"/Promise<void>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"dbExists\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<boolean>\",\"filePath\":null,\"qualifiedName\":\"/Promise<boolean>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[{\"name\":\"databaseName\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"start\",\"returnType\":null,\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"stop\",\"returnType\":null,\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"setMaxAllowedPacketSize\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<void>\",\"filePath\":null,\"qualifiedName\":\"/Promise<void>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[]},{\"name\":\"getTableManager\",\"returnType\":{\"packageName\":\"@proteinjs/db\",\"name\":\"TableManager\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db/TableManager\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"handleCaseSensitivity\",\"returnType\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"tableName\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"columnName\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"caseSensitive\",\"type\":{\"packageName\":\"\",\"name\":\"boolean\",\"filePath\":null,\"qualifiedName\":\"/boolean\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"runQuery\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<SerializedRecord[]>\",\"filePath\":null,\"qualifiedName\":\"/Promise<SerializedRecord[]>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"generateStatement\",\"type\":{\"packageName\":\"\",\"name\":\"(config: DbDriverQueryStatementConfig) => Statement\",\"filePath\":null,\"qualifiedName\":\"/(config: DbDriverQueryStatementConfig) => Statement\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"runDml\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<number>\",\"filePath\":null,\"qualifiedName\":\"/Promise<number>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"generateStatement\",\"type\":{\"packageName\":\"\",\"name\":\"(config: DbDriverDmlStatementConfig) => Statement\",\"filePath\":null,\"qualifiedName\":\"/(config: DbDriverDmlStatementConfig) => Statement\",\"typeParameters\":null,\"directParents\":null}}]}],\"typeParameters\":[],\"directParentInterfaces\":[{\"packageName\":\"@proteinjs/db\",\"name\":\"DbDriver\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db/DbDriver\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"directParentClasses\":[],\"sourceType\":2}},{\"v\":\"@proteinjs/db/DbDriver\"},{\"v\":\"@proteinjs/db-driver-knex/KnexSchemaOperations\",\"value\":{\"packageName\":\"@proteinjs/db-driver-knex\",\"name\":\"KnexSchemaOperations\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/db/packages/drivers/knex/src/KnexSchemaOperations.ts\",\"qualifiedName\":\"@proteinjs/db-driver-knex/KnexSchemaOperations\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"logger\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"},{\"name\":\"knexDriver\",\"type\":{\"packageName\":\"@proteinjs/db-driver-knex\",\"name\":\"KnexDriver\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db-driver-knex/KnexDriver\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"}],\"methods\":[{\"name\":\"createTable\",\"returnType\":null,\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"table\",\"type\":{\"packageName\":\"\",\"name\":\"Table<any>\",\"filePath\":null,\"qualifiedName\":\"/Table<any>\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"alterTable\",\"returnType\":null,\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"table\",\"type\":{\"packageName\":\"\",\"name\":\"Table<any>\",\"filePath\":null,\"qualifiedName\":\"/Table<any>\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"tableChanges\",\"type\":{\"packageName\":\"@proteinjs/db\",\"name\":\"TableChanges\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db/TableChanges\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"createColumn\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[{\"name\":\"column\",\"type\":{\"packageName\":\"\",\"name\":\"Column<any, any>\",\"filePath\":null,\"qualifiedName\":\"/Column<any, any>\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"table\",\"type\":{\"packageName\":\"\",\"name\":\"Table<any>\",\"filePath\":null,\"qualifiedName\":\"/Table<any>\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"tableBuilder\",\"type\":{\"packageName\":\"\",\"name\":\"knex.TableBuilder\",\"filePath\":null,\"qualifiedName\":\"/knex.TableBuilder\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"tableChanges\",\"type\":{\"packageName\":\"@proteinjs/db\",\"name\":\"TableChanges\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db/TableChanges\",\"typeParameters\":null,\"directParents\":null}}]}],\"typeParameters\":[],\"directParentInterfaces\":[{\"packageName\":\"@proteinjs/db\",\"name\":\"SchemaOperations\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db/SchemaOperations\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"directParentClasses\":[],\"sourceType\":2}},{\"v\":\"@proteinjs/db/SchemaOperations\"}],\"edges\":[{\"v\":\"@proteinjs/db-driver-knex/KnexDriver\",\"w\":\"@proteinjs/db/DbDriver\",\"value\":\"implements interface\"},{\"v\":\"@proteinjs/db-driver-knex/KnexSchemaOperations\",\"w\":\"@proteinjs/db/SchemaOperations\",\"value\":\"implements interface\"}]}";
|
|
17
|
+
|
|
16
18
|
|
|
17
19
|
/** Generate Source Links */
|
|
18
20
|
|
|
@@ -20,13 +22,15 @@ import { KnexDriver } from '../src/KnexDriver';
|
|
|
20
22
|
import { KnexSchemaOperations } from '../src/KnexSchemaOperations';
|
|
21
23
|
|
|
22
24
|
const sourceLinks = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
'@proteinjs/db-driver-knex/KnexDriver': KnexDriver,
|
|
26
|
+
'@proteinjs/db-driver-knex/KnexSchemaOperations': KnexSchemaOperations,
|
|
25
27
|
};
|
|
26
28
|
|
|
29
|
+
|
|
27
30
|
/** Load Source Graph and Links */
|
|
28
31
|
|
|
29
32
|
import { SourceRepository } from '@proteinjs/reflection';
|
|
30
33
|
SourceRepository.merge(sourceGraph, sourceLinks);
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
|
|
36
|
+
export * from '../index';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proteinjs/db-driver-knex",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "Db driver for Knex",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,17 +22,18 @@
|
|
|
22
22
|
"test": "jest"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@proteinjs/db": "^1.5.
|
|
26
|
-
"@proteinjs/db-query": "^1.2.
|
|
27
|
-
"@proteinjs/
|
|
28
|
-
"@proteinjs/
|
|
25
|
+
"@proteinjs/db": "^1.5.8",
|
|
26
|
+
"@proteinjs/db-query": "^1.2.8",
|
|
27
|
+
"@proteinjs/logger": "1.0.5",
|
|
28
|
+
"@proteinjs/reflection": "1.1.9",
|
|
29
|
+
"@proteinjs/util": "1.4.1",
|
|
29
30
|
"knex": "0.21.5",
|
|
30
31
|
"moment": "2.29.4",
|
|
31
32
|
"mysql": "2.18.1",
|
|
32
33
|
"uuid": "8.3.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@proteinjs/reflection-build": "1.0.
|
|
36
|
+
"@proteinjs/reflection-build": "1.0.24",
|
|
36
37
|
"@types/jest": "29.5.5",
|
|
37
38
|
"@types/knex": "0.16.1",
|
|
38
39
|
"@types/node": "14.0.27",
|
|
@@ -47,6 +48,5 @@
|
|
|
47
48
|
"typescript": "5.2.2"
|
|
48
49
|
},
|
|
49
50
|
"main": "./dist/generated/index.js",
|
|
50
|
-
"types": "./dist/generated/index.d.ts"
|
|
51
|
-
"gitHead": "951ea0c83422fb75a4778f85031cfa1cb59852e9"
|
|
51
|
+
"types": "./dist/generated/index.d.ts"
|
|
52
52
|
}
|
package/src/KnexDriver.ts
CHANGED
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
tableByName,
|
|
10
10
|
} from '@proteinjs/db';
|
|
11
11
|
import { KnexConfig } from './KnexConfig';
|
|
12
|
-
import { Logger } from '@proteinjs/
|
|
12
|
+
import { Logger } from '@proteinjs/logger';
|
|
13
13
|
import { Statement } from '@proteinjs/db-query';
|
|
14
14
|
import { KnexSchemaOperations } from './KnexSchemaOperations';
|
|
15
15
|
import { KnexColumnTypeFactory } from './KnexColumnTypeFactory';
|
|
16
16
|
|
|
17
17
|
export class KnexDriver implements DbDriver {
|
|
18
18
|
private static KNEX: knex;
|
|
19
|
-
private logger = new Logger(this.constructor.name);
|
|
19
|
+
private logger = new Logger({ name: this.constructor.name });
|
|
20
20
|
private config: KnexConfig;
|
|
21
21
|
private knexConfig: any;
|
|
22
22
|
public getTable: ((name: string) => Table<any>) | undefined;
|
|
@@ -77,7 +77,7 @@ export class KnexDriver implements DbDriver {
|
|
|
77
77
|
await this.getKnex().raw('SET GLOBAL max_allowed_packet=1073741824;');
|
|
78
78
|
await this.getKnex().destroy();
|
|
79
79
|
KnexDriver.KNEX = knex(this.knexConfig);
|
|
80
|
-
this.logger.info('Set global max_allowed_packet size to 1gb');
|
|
80
|
+
this.logger.info({ message: 'Set global max_allowed_packet size to 1gb' });
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
getTableManager(): TableManager {
|
|
@@ -122,7 +122,7 @@ export class KnexDriver implements DbDriver {
|
|
|
122
122
|
try {
|
|
123
123
|
return (await this.getKnex().raw(sql, params as any))[0]; // returns 2 arrays, first is records, second is metadata per record
|
|
124
124
|
} catch (error: any) {
|
|
125
|
-
this.logger.error(`Failed when executing
|
|
125
|
+
this.logger.error({ message: `Failed when executing sql`, obj: { sql }, error });
|
|
126
126
|
throw error;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as knex from 'knex';
|
|
2
|
-
import { Logger } from '@proteinjs/
|
|
2
|
+
import { Logger } from '@proteinjs/logger';
|
|
3
3
|
import { Column, Table, SchemaOperations, TableChanges } from '@proteinjs/db';
|
|
4
4
|
import { KnexDriver } from './KnexDriver';
|
|
5
5
|
import { getColumnFactory } from './getColumnFactory';
|
|
6
6
|
|
|
7
7
|
export class KnexSchemaOperations implements SchemaOperations {
|
|
8
|
-
private logger = new Logger(this.constructor.name);
|
|
8
|
+
private logger = new Logger({ name: this.constructor.name });
|
|
9
9
|
|
|
10
10
|
constructor(private knexDriver: KnexDriver) {}
|
|
11
11
|
|
|
@@ -24,11 +24,11 @@ export class KnexSchemaOperations implements SchemaOperations {
|
|
|
24
24
|
for (const columnPropertyName in table.columns) {
|
|
25
25
|
const column = table.columns[columnPropertyName];
|
|
26
26
|
this.createColumn(column, table, tableBuilder);
|
|
27
|
-
this.logger.info(`[${table.name}] Creating column: ${column.name}`);
|
|
27
|
+
this.logger.info({ message: `[${table.name}] Creating column: ${column.name}` });
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
tableBuilder.primary(['id']);
|
|
31
|
-
this.logger.info(`[${table.name}] Creating primary key: id`);
|
|
31
|
+
this.logger.info({ message: `[${table.name}] Creating primary key: id` });
|
|
32
32
|
|
|
33
33
|
if (table.indexes) {
|
|
34
34
|
for (const index of table.indexes) {
|
|
@@ -36,7 +36,7 @@ export class KnexSchemaOperations implements SchemaOperations {
|
|
|
36
36
|
(columnPropertyName) => table.columns[columnPropertyName as string].name
|
|
37
37
|
);
|
|
38
38
|
tableBuilder.index(columnNames, index.name);
|
|
39
|
-
this.logger.info(`[${table.name}] Creating index: ${columnNames}`);
|
|
39
|
+
this.logger.info({ message: `[${table.name}] Creating index: ${columnNames}` });
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
})
|
|
@@ -64,28 +64,30 @@ export class KnexSchemaOperations implements SchemaOperations {
|
|
|
64
64
|
.table(table.name, (tableBuilder: knex.TableBuilder) => {
|
|
65
65
|
for (const columnPropertyName of tableChanges.columnsToCreate) {
|
|
66
66
|
const column = table.columns[columnPropertyName];
|
|
67
|
-
this.logger.info(`[${table.name}] Creating column: ${column.name}`);
|
|
67
|
+
this.logger.info({ message: `[${table.name}] Creating column: ${column.name}` });
|
|
68
68
|
this.createColumn(column, table, tableBuilder, tableChanges);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
for (const column of tableChanges.columnsWithUniqueConstraintsToDrop) {
|
|
72
72
|
tableBuilder.dropUnique([column]);
|
|
73
|
-
this.logger.info(`[${table.name}.${column}] Dropping unique constraint`);
|
|
73
|
+
this.logger.info({ message: `[${table.name}.${column}] Dropping unique constraint` });
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
for (const column of tableChanges.columnsWithForeignKeysToDrop) {
|
|
77
77
|
tableBuilder.dropForeign([column]);
|
|
78
|
-
this.logger.info(`[${table.name}.${column}] Dropping foreign key`);
|
|
78
|
+
this.logger.info({ message: `[${table.name}.${column}] Dropping foreign key` });
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
for (const index of tableChanges.indexesToDrop) {
|
|
82
82
|
tableBuilder.dropIndex(index.columns);
|
|
83
|
-
this.logger.info(`[${table.name}] Dropping index: ${JSON.stringify(index)}`);
|
|
83
|
+
this.logger.info({ message: `[${table.name}] Dropping index: ${JSON.stringify(index)}` });
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
for (const columnPropertyName of tableChanges.columnsToAlter) {
|
|
87
87
|
const column = table.columns[columnPropertyName];
|
|
88
|
-
this.logger.info(
|
|
88
|
+
this.logger.info({
|
|
89
|
+
message: `[${table.name}.${column.name}] Altering column type to: ${column.constructor.name}`,
|
|
90
|
+
});
|
|
89
91
|
this.createColumn(column, table, tableBuilder, tableChanges).alter();
|
|
90
92
|
}
|
|
91
93
|
|
|
@@ -96,12 +98,12 @@ export class KnexSchemaOperations implements SchemaOperations {
|
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
tableBuilder.renameColumn(column.oldName, column.name);
|
|
99
|
-
this.logger.info(`[${table.name}] Renaming column: ${column.oldName} -> ${column.name}`);
|
|
101
|
+
this.logger.info({ message: `[${table.name}] Renaming column: ${column.oldName} -> ${column.name}` });
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
for (const index of tableChanges.indexesToCreate) {
|
|
103
105
|
tableBuilder.index(index.columns);
|
|
104
|
-
this.logger.info(`[${table.name}] Creating index:
|
|
106
|
+
this.logger.info({ message: `[${table.name}] Creating index:`, obj: { index } });
|
|
105
107
|
}
|
|
106
108
|
})
|
|
107
109
|
.catch((reason: any) => {
|
|
@@ -127,7 +129,7 @@ export class KnexSchemaOperations implements SchemaOperations {
|
|
|
127
129
|
(!tableChanges || tableChanges.columnsWithUniqueConstraintsToCreate.includes(column.name))
|
|
128
130
|
) {
|
|
129
131
|
columnBuilder.unique(column.options.unique.indexName);
|
|
130
|
-
this.logger.info(`[${table.name}.${column.name}] Adding unique constraint`);
|
|
132
|
+
this.logger.info({ message: `[${table.name}.${column.name}] Adding unique constraint` });
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
if (
|
|
@@ -135,7 +137,9 @@ export class KnexSchemaOperations implements SchemaOperations {
|
|
|
135
137
|
(!tableChanges || tableChanges.columnsWithForeignKeysToCreate.includes(column.name))
|
|
136
138
|
) {
|
|
137
139
|
columnBuilder.references('id').inTable(`${this.knexDriver.getDbName()}.${column.options.references.table}`);
|
|
138
|
-
this.logger.info(
|
|
140
|
+
this.logger.info({
|
|
141
|
+
message: `[${table.name}.${column.name}] Adding foreign key -> ${column.options.references.table}.id`,
|
|
142
|
+
});
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
if (typeof column.options?.nullable !== 'undefined') {
|
|
@@ -145,7 +149,9 @@ export class KnexSchemaOperations implements SchemaOperations {
|
|
|
145
149
|
columnBuilder.notNullable();
|
|
146
150
|
}
|
|
147
151
|
|
|
148
|
-
this.logger.info(
|
|
152
|
+
this.logger.info({
|
|
153
|
+
message: `[${table.name}.${column.name}] Adding constraint nullable: ${column.options?.nullable}`,
|
|
154
|
+
});
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
return columnBuilder;
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Brent Bahry
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|