dbgate-tools 5.2.7 → 5.2.9
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/lib/DatabaseAnalyser.d.ts +2 -0
- package/lib/DatabaseAnalyser.js +1 -0
- package/lib/SqlDumper.js +16 -7
- package/lib/alterPlan.d.ts +1 -1
- package/lib/diffTools.d.ts +1 -1
- package/lib/getLogger.d.ts +2 -2
- package/lib/getLogger.js +20 -16
- package/lib/structureTools.js +3 -0
- package/package.json +4 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DatabaseInfo, DatabaseModification, EngineDriver, SqlDialect } from 'dbgate-types';
|
|
2
|
+
import { type Logger } from 'pinomin';
|
|
2
3
|
export declare class DatabaseAnalyser {
|
|
3
4
|
pool: any;
|
|
4
5
|
driver: EngineDriver;
|
|
@@ -7,6 +8,7 @@ export declare class DatabaseAnalyser {
|
|
|
7
8
|
singleObjectFilter: any;
|
|
8
9
|
singleObjectId: string;
|
|
9
10
|
dialect: SqlDialect;
|
|
11
|
+
logger: Logger;
|
|
10
12
|
constructor(pool: any, driver: EngineDriver, version: any);
|
|
11
13
|
_runAnalysis(): Promise<DatabaseInfo>;
|
|
12
14
|
_getFastSnapshot(): Promise<DatabaseInfo>;
|
package/lib/DatabaseAnalyser.js
CHANGED
|
@@ -42,6 +42,7 @@ class DatabaseAnalyser {
|
|
|
42
42
|
this.driver = driver;
|
|
43
43
|
this.singleObjectId = null;
|
|
44
44
|
this.dialect = ((driver === null || driver === void 0 ? void 0 : driver.dialectByVersion) && (driver === null || driver === void 0 ? void 0 : driver.dialectByVersion(version))) || (driver === null || driver === void 0 ? void 0 : driver.dialect);
|
|
45
|
+
this.logger = logger;
|
|
45
46
|
}
|
|
46
47
|
_runAnalysis() {
|
|
47
48
|
return __awaiter(this, void 0, void 0, function* () {
|
package/lib/SqlDumper.js
CHANGED
|
@@ -12,18 +12,18 @@ const isArray_1 = __importDefault(require("lodash/isArray"));
|
|
|
12
12
|
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
13
13
|
const v1_1 = __importDefault(require("uuid/v1"));
|
|
14
14
|
class SqlDumper {
|
|
15
|
-
constructor(driver) {
|
|
16
|
-
this.s = '';
|
|
17
|
-
this.indentLevel = 0;
|
|
18
|
-
this.driver = driver;
|
|
19
|
-
this.dialect = driver.dialect;
|
|
20
|
-
}
|
|
21
15
|
static convertKeywordCase(keyword) {
|
|
22
16
|
var _a, _b;
|
|
23
17
|
if (this.keywordsCase == 'lowerCase')
|
|
24
18
|
return (_a = keyword === null || keyword === void 0 ? void 0 : keyword.toString()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
25
19
|
return (_b = keyword === null || keyword === void 0 ? void 0 : keyword.toString()) === null || _b === void 0 ? void 0 : _b.toUpperCase();
|
|
26
20
|
}
|
|
21
|
+
constructor(driver) {
|
|
22
|
+
this.s = '';
|
|
23
|
+
this.indentLevel = 0;
|
|
24
|
+
this.driver = driver;
|
|
25
|
+
this.dialect = driver.dialect;
|
|
26
|
+
}
|
|
27
27
|
endCommand() {
|
|
28
28
|
this.putRaw(';\n');
|
|
29
29
|
}
|
|
@@ -192,7 +192,16 @@ class SqlDumper {
|
|
|
192
192
|
this.put(' ^persisted');
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
195
|
-
|
|
195
|
+
const type = column.dataType || this.dialect.fallbackDataType;
|
|
196
|
+
const typeWithValues = type.match(/([^(]+)(\(.+[^)]\))/);
|
|
197
|
+
if (typeWithValues === null || typeWithValues === void 0 ? void 0 : typeWithValues.length) {
|
|
198
|
+
typeWithValues.shift();
|
|
199
|
+
this.putRaw(SqlDumper.convertKeywordCase(typeWithValues.shift()));
|
|
200
|
+
this.putRaw(typeWithValues);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
this.putRaw(SqlDumper.convertKeywordCase(type));
|
|
204
|
+
}
|
|
196
205
|
if (column.autoIncrement) {
|
|
197
206
|
this.autoIncrement();
|
|
198
207
|
}
|
package/lib/alterPlan.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ interface AlterOperation_FillPreloadedRows {
|
|
|
70
70
|
key: string[];
|
|
71
71
|
insertOnly: string[];
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
type AlterOperation = AlterOperation_CreateColumn | AlterOperation_ChangeColumn | AlterOperation_DropColumn | AlterOperation_CreateConstraint | AlterOperation_ChangeConstraint | AlterOperation_DropConstraint | AlterOperation_CreateTable | AlterOperation_DropTable | AlterOperation_RenameTable | AlterOperation_RenameColumn | AlterOperation_RenameConstraint | AlterOperation_CreateSqlObject | AlterOperation_DropSqlObject | AlterOperation_RecreateTable | AlterOperation_FillPreloadedRows;
|
|
74
74
|
export declare class AlterPlan {
|
|
75
75
|
wholeOldDb: DatabaseInfo;
|
|
76
76
|
wholeNewDb: DatabaseInfo;
|
package/lib/diffTools.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ColumnInfo, DatabaseInfo, EngineDriver, SqlObjectInfo, TableInfo } from 'dbgate-types';
|
|
2
2
|
import { AlterPlan } from './alterPlan';
|
|
3
|
-
|
|
3
|
+
type DbDiffSchemaMode = 'strict' | 'ignore' | 'ignoreImplicit';
|
|
4
4
|
export interface DbDiffOptions {
|
|
5
5
|
ignoreCase?: boolean;
|
|
6
6
|
schemaMode?: DbDiffSchemaMode;
|
package/lib/getLogger.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Logger } from 'pinomin';
|
|
2
|
-
export declare function
|
|
1
|
+
import { Logger, type LogConfig } from 'pinomin';
|
|
2
|
+
export declare function setLogConfig(value: LogConfig): void;
|
|
3
3
|
export declare function setLoggerName(value: any): void;
|
|
4
4
|
export declare function getLogger(caller?: string): Logger;
|
package/lib/getLogger.js
CHANGED
|
@@ -4,31 +4,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.getLogger = exports.setLoggerName = exports.
|
|
7
|
+
exports.getLogger = exports.setLoggerName = exports.setLogConfig = void 0;
|
|
8
8
|
const pinomin_1 = __importDefault(require("pinomin"));
|
|
9
|
-
let
|
|
9
|
+
let _logConfig;
|
|
10
10
|
let _name = null;
|
|
11
|
-
const
|
|
11
|
+
const defaultLogConfig = {
|
|
12
12
|
base: { pid: (_a = global === null || global === void 0 ? void 0 : global.process) === null || _a === void 0 ? void 0 : _a.pid },
|
|
13
13
|
targets: [{ type: 'console', level: 'info' }],
|
|
14
|
-
}
|
|
15
|
-
function
|
|
16
|
-
|
|
14
|
+
};
|
|
15
|
+
function setLogConfig(value) {
|
|
16
|
+
_logConfig = value;
|
|
17
17
|
}
|
|
18
|
-
exports.
|
|
18
|
+
exports.setLogConfig = setLogConfig;
|
|
19
19
|
function setLoggerName(value) {
|
|
20
20
|
_name = value;
|
|
21
21
|
}
|
|
22
22
|
exports.setLoggerName = setLoggerName;
|
|
23
23
|
function getLogger(caller) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
return (0, pinomin_1.default)({
|
|
25
|
+
getConfig: () => {
|
|
26
|
+
const config = _logConfig || defaultLogConfig;
|
|
27
|
+
if (caller) {
|
|
28
|
+
const props = { caller };
|
|
29
|
+
if (_name) {
|
|
30
|
+
props['name'] = _name;
|
|
31
|
+
}
|
|
32
|
+
return Object.assign(Object.assign({}, config), { base: Object.assign(Object.assign({}, config.base), props) });
|
|
33
|
+
}
|
|
34
|
+
return config;
|
|
35
|
+
},
|
|
36
|
+
});
|
|
33
37
|
}
|
|
34
38
|
exports.getLogger = getLogger;
|
package/lib/structureTools.js
CHANGED
|
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.isCollectionInfo = exports.isViewInfo = exports.isTableInfo = exports.isTableColumnUnique = exports.extendDatabaseInfoFromApps = exports.extendDatabaseInfo = exports.extendTableInfo = exports.addTableDependencies = void 0;
|
|
7
7
|
const flatten_1 = __importDefault(require("lodash/flatten"));
|
|
8
8
|
function addTableDependencies(db) {
|
|
9
|
+
if (!db.tables) {
|
|
10
|
+
return db;
|
|
11
|
+
}
|
|
9
12
|
const allForeignKeys = (0, flatten_1.default)(db.tables.map(x => x.foreignKeys || []));
|
|
10
13
|
return Object.assign(Object.assign({}, db), { tables: db.tables.map(table => (Object.assign(Object.assign({}, table), { dependencies: allForeignKeys.filter(x => x.refSchemaName == table.schemaName && x.refTableName == table.pureName) }))) });
|
|
11
14
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.2.
|
|
2
|
+
"version": "5.2.9",
|
|
3
3
|
"name": "dbgate-tools",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"typings": "lib/index.d.ts",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^13.7.0",
|
|
28
|
-
"dbgate-types": "^5.2.
|
|
28
|
+
"dbgate-types": "^5.2.9",
|
|
29
29
|
"jest": "^24.9.0",
|
|
30
30
|
"ts-jest": "^25.2.1",
|
|
31
31
|
"typescript": "^4.4.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"dbgate-query-splitter": "^4.9.3",
|
|
35
|
-
"dbgate-sqltree": "^5.2.
|
|
35
|
+
"dbgate-sqltree": "^5.2.9",
|
|
36
36
|
"debug": "^4.3.4",
|
|
37
37
|
"json-stable-stringify": "^1.0.1",
|
|
38
38
|
"lodash": "^4.17.21",
|
|
39
|
-
"pinomin": "^1.0.
|
|
39
|
+
"pinomin": "^1.0.4",
|
|
40
40
|
"uuid": "^3.4.0"
|
|
41
41
|
}
|
|
42
42
|
}
|