fix datasource provisioning with direct DB connection enabled, closes #688

This commit is contained in:
Alexander Zobnin
2019-03-05 14:13:05 +03:00
parent a69764ed5f
commit e52e296c11
2 changed files with 45 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
import _ from 'lodash';
/**
* Query format migration.
* This module can detect query format version and make migration.
@@ -54,13 +56,14 @@ export function migrateDSConfig(jsonData) {
if (!jsonData) {
jsonData = {};
}
const oldVersion = jsonData.schema || 1;
jsonData.schema = DS_CONFIG_SCHEMA;
if (oldVersion === DS_CONFIG_SCHEMA) {
if (!shouldMigrateDSConfig(jsonData)) {
return jsonData;
}
const oldVersion = jsonData.schema || 1;
jsonData.schema = DS_CONFIG_SCHEMA;
if (oldVersion < 2) {
const dbConnectionOptions = jsonData.dbConnection || {};
jsonData.dbConnectionEnable = dbConnectionOptions.enable || false;
@@ -70,3 +73,13 @@ export function migrateDSConfig(jsonData) {
return jsonData;
}
function shouldMigrateDSConfig(jsonData): boolean {
if (jsonData.dbConnection && !_.isEmpty(jsonData.dbConnection)) {
return true;
}
if (jsonData.schema && jsonData.schema !== DS_CONFIG_SCHEMA) {
return true;
}
return false;
}