From 94ecae301b5332bf3fefb80468282e461d5efac4 Mon Sep 17 00:00:00 2001 From: Vitalii Yarmus Date: Tue, 21 Dec 2021 12:00:31 +0200 Subject: [PATCH] FE: fixed configs to enable FE of delta model --- forward_engineering/api.js | 57 +++++++++++++++------------------ forward_engineering/config.json | 34 +++++++------------- localization/en.json | 1 + 3 files changed, 37 insertions(+), 55 deletions(-) diff --git a/forward_engineering/api.js b/forward_engineering/api.js index 0210e88..779c8a6 100644 --- a/forward_engineering/api.js +++ b/forward_engineering/api.js @@ -4,43 +4,36 @@ const applyToInstanceHelper = require('./applyToInstanceHelper'); module.exports = { generateScript(data, logger, callback, app) { - callback(new Error('Forward-Engineering of delta model on entity level is not supported')); + const { + getAlterContainersScripts, + getAlterCollectionsScripts, + getAlterViewScripts, + getAlterModelDefinitionsScripts, + } = require('./helpers/alterScriptFromDeltaHelper'); + + const collection = JSON.parse(data.jsonSchema); + if (!collection) { + throw new Error( + '"comparisonModelCollection" is not found. Alter script can be generated only from Delta model', + ); + } + + const dbVersion = data.modelData[0]?.dbVersion; + const containersScripts = getAlterContainersScripts(collection); + const collectionsScripts = getAlterCollectionsScripts(collection, app, dbVersion); + const viewScripts = getAlterViewScripts(collection, app); + const modelDefinitionsScripts = getAlterModelDefinitionsScripts(collection, app); + + callback( + null, + [...containersScripts, ...collectionsScripts, ...viewScripts, ...modelDefinitionsScripts].join('\n\n'), + ); }, generateViewScript(data, logger, callback, app) { callback(new Error('Forward-Engineering of delta model on view level is not supported')); }, generateContainerScript(data, logger, callback, app) { - try { - const { - getComparisonModelCollection, - getAlterContainersScripts, - getAlterCollectionsScripts, - getAlterViewScripts, - getAlterModelDefinitionsScripts, - } = require('./helpers/alterScriptFromDeltaHelper'); - - const collection = getComparisonModelCollection(data.collections); - if (!collection) { - throw new Error( - '"comparisonModelCollection" is not found. Alter script can be generated only from Delta model', - ); - } - - const dbVersion = data.modelData[0]?.dbVersion; - const containersScripts = getAlterContainersScripts(collection); - const collectionsScripts = getAlterCollectionsScripts(collection, app, dbVersion); - const viewScripts = getAlterViewScripts(collection, app); - const modelDefinitionsScripts = getAlterModelDefinitionsScripts(collection, app); - - callback( - null, - [...containersScripts, ...collectionsScripts, ...viewScripts, ...modelDefinitionsScripts].join('\n\n'), - ); - } catch (e) { - logger.log('error', { message: e.message, stack: e.stack }, 'Cassandra Forward-Engineering Error'); - - callback({ message: e.message, stack: e.stack }); - } + callback(new Error('Forward-Engineering of delta model on container level is not supported')); }, getDatabases(connectionInfo, logger, callback, app) { logger.progress({ message: 'Find all databases' }); diff --git a/forward_engineering/config.json b/forward_engineering/config.json index 3211eee..fb157b3 100644 --- a/forward_engineering/config.json +++ b/forward_engineering/config.json @@ -1,30 +1,14 @@ { - "options": [ + "type": "ddl", + "ddlType": "plugin", + "mode": "pgsql", + "fileExtensions": [ { - "name": "Create Script", - "keyword": "create", - "type": "ddl", - "ddlType": "plugin", - "mode": "pgsql", - "fileExtensions": [ - { - "value": "sql", - "label": "SQL" - } - ] - }, - { - "name": "Alter Script from Delta model", - "keyword": "alterFromDelta", - "cliOnly": true, - "fileExtensions": [ - { - "value": "sql", - "label": "SQL" - } - ] + "value": "sql", + "label": "SQL" } ], + "hasUpdateScript": false, "namePrefix": "PostgreSQL", "level": { "container": true, @@ -39,5 +23,9 @@ "feLevelSelector": { "container": true, "model": true + }, + "compMode": { + "entity": true, + "container": false } } \ No newline at end of file diff --git a/localization/en.json b/localization/en.json index 9212313..4b8197a 100644 --- a/localization/en.json +++ b/localization/en.json @@ -8,6 +8,7 @@ "MAIN_MENU___INSERT_FIELD": "Insert Column", "MAIN_MENU___APPEND_FIELD": "Append Column", "MAIN_MENU___REVERSE_DB_COLLECTIONS": "PostgreSQL schemas...", + "MAIN_MENU___FORWARD_CHANGE_COLLECTIONS": "PostgreSQL Alter Script", "TOOLBAR___ADD_BUCKET": "Add schema", "TOOLBAR___ADD_COLLECTION": "Add table", "TOOLBAR___ADD_VIEW": "Add View",