Skip to content

Commit

Permalink
FE: fixed configs to enable FE of delta model
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalii4as committed Dec 21, 2021
1 parent 26c29ef commit 94ecae3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 55 deletions.
57 changes: 25 additions & 32 deletions forward_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
34 changes: 11 additions & 23 deletions forward_engineering/config.json
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -39,5 +23,9 @@
"feLevelSelector": {
"container": true,
"model": true
},
"compMode": {
"entity": true,
"container": false
}
}
1 change: 1 addition & 0 deletions localization/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 94ecae3

Please sign in to comment.