mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 03:36:01 +00:00
fixes
This commit is contained in:
@@ -4,6 +4,7 @@ const { ScriptDrivedDeployer } = require('dbgate-datalib');
|
|||||||
const connectUtility = require('../utility/connectUtility');
|
const connectUtility = require('../utility/connectUtility');
|
||||||
const requireEngineDriver = require('../utility/requireEngineDriver');
|
const requireEngineDriver = require('../utility/requireEngineDriver');
|
||||||
const loadModelFolder = require('../utility/loadModelFolder');
|
const loadModelFolder = require('../utility/loadModelFolder');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
|
||||||
async function deployDb({
|
async function deployDb({
|
||||||
connection,
|
connection,
|
||||||
@@ -24,7 +25,8 @@ async function deployDb({
|
|||||||
const scriptDeployer = new ScriptDrivedDeployer(
|
const scriptDeployer = new ScriptDrivedDeployer(
|
||||||
dbhan,
|
dbhan,
|
||||||
driver,
|
driver,
|
||||||
loadedDbModel ?? (await loadModelFolder(modelFolder))
|
Array.isArray(loadedDbModel) ? loadedDbModel : modelFolder ? await loadModelFolder(modelFolder) : [],
|
||||||
|
crypto
|
||||||
);
|
);
|
||||||
await scriptDeployer.runPre();
|
await scriptDeployer.runPre();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { DatabaseModelFile, extractErrorLogData, getLogger, runCommandOnDriver, runQueryOnDriver } from 'dbgate-tools';
|
import { DatabaseModelFile, extractErrorLogData, getLogger, runCommandOnDriver, runQueryOnDriver } from 'dbgate-tools';
|
||||||
import { EngineDriver } from 'dbgate-types';
|
import { EngineDriver } from 'dbgate-types';
|
||||||
import crypto from 'crypto';
|
|
||||||
import _sortBy from 'lodash/sortBy';
|
import _sortBy from 'lodash/sortBy';
|
||||||
|
|
||||||
const logger = getLogger('ScriptDrivedDeployer');
|
const logger = getLogger('ScriptDrivedDeployer');
|
||||||
@@ -24,7 +23,7 @@ export class ScriptDrivedDeployer {
|
|||||||
|
|
||||||
journalItems: DeployScriptJournalItem[] = [];
|
journalItems: DeployScriptJournalItem[] = [];
|
||||||
|
|
||||||
constructor(public dbhan: any, public driver: EngineDriver, public files: DatabaseModelFile[]) {
|
constructor(public dbhan: any, public driver: EngineDriver, public files: DatabaseModelFile[], public crypto: any) {
|
||||||
this.predeploy = files.filter(x => x.name.endsWith('.predeploy.sql'));
|
this.predeploy = files.filter(x => x.name.endsWith('.predeploy.sql'));
|
||||||
this.uninstall = files.filter(x => x.name.endsWith('.uninstall.sql'));
|
this.uninstall = files.filter(x => x.name.endsWith('.uninstall.sql'));
|
||||||
this.install = files.filter(x => x.name.endsWith('.install.sql'));
|
this.install = files.filter(x => x.name.endsWith('.install.sql'));
|
||||||
@@ -145,7 +144,7 @@ export class ScriptDrivedDeployer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async runFile(file: DatabaseModelFile, category: string) {
|
async runFile(file: DatabaseModelFile, category: string) {
|
||||||
const hash = crypto.createHash('md5').update(file.text.trim()).digest('hex');
|
const hash = this.crypto.createHash('md5').update(file.text.trim()).digest('hex');
|
||||||
const journalItem = this.journalItems.find(x => x.name == file.name);
|
const journalItem = this.journalItems.find(x => x.name == file.name);
|
||||||
const isEqual = journalItem && journalItem.script_hash == hash;
|
const isEqual = journalItem && journalItem.script_hash == hash;
|
||||||
|
|
||||||
@@ -166,7 +165,7 @@ export class ScriptDrivedDeployer {
|
|||||||
await this.runFileCore(
|
await this.runFileCore(
|
||||||
uninstallFile,
|
uninstallFile,
|
||||||
'uninstall',
|
'uninstall',
|
||||||
crypto.createHash('md5').update(uninstallFile.text.trim()).digest('hex')
|
this.crypto.createHash('md5').update(uninstallFile.text.trim()).digest('hex')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await this.runFileCore(file, category, hash);
|
await this.runFileCore(file, category, hash);
|
||||||
|
|||||||
@@ -312,6 +312,14 @@ export function safeJsonParse(json, defaultValue?, logError = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function safeCompileRegExp(regex: string, flags: string) {
|
||||||
|
try {
|
||||||
|
return new RegExp(regex, flags);
|
||||||
|
} catch (err) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function shouldOpenMultilineDialog(value) {
|
export function shouldOpenMultilineDialog(value) {
|
||||||
if (_isString(value)) {
|
if (_isString(value)) {
|
||||||
if (value.includes('\n')) {
|
if (value.includes('\n')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user