Skip to content

Commit 94ecae3

Browse files
committed
FE: fixed configs to enable FE of delta model
1 parent 26c29ef commit 94ecae3

File tree

3 files changed

+37
-55
lines changed

3 files changed

+37
-55
lines changed

forward_engineering/api.js

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,36 @@ const applyToInstanceHelper = require('./applyToInstanceHelper');
44

55
module.exports = {
66
generateScript(data, logger, callback, app) {
7-
callback(new Error('Forward-Engineering of delta model on entity level is not supported'));
7+
const {
8+
getAlterContainersScripts,
9+
getAlterCollectionsScripts,
10+
getAlterViewScripts,
11+
getAlterModelDefinitionsScripts,
12+
} = require('./helpers/alterScriptFromDeltaHelper');
13+
14+
const collection = JSON.parse(data.jsonSchema);
15+
if (!collection) {
16+
throw new Error(
17+
'"comparisonModelCollection" is not found. Alter script can be generated only from Delta model',
18+
);
19+
}
20+
21+
const dbVersion = data.modelData[0]?.dbVersion;
22+
const containersScripts = getAlterContainersScripts(collection);
23+
const collectionsScripts = getAlterCollectionsScripts(collection, app, dbVersion);
24+
const viewScripts = getAlterViewScripts(collection, app);
25+
const modelDefinitionsScripts = getAlterModelDefinitionsScripts(collection, app);
26+
27+
callback(
28+
null,
29+
[...containersScripts, ...collectionsScripts, ...viewScripts, ...modelDefinitionsScripts].join('\n\n'),
30+
);
831
},
932
generateViewScript(data, logger, callback, app) {
1033
callback(new Error('Forward-Engineering of delta model on view level is not supported'));
1134
},
1235
generateContainerScript(data, logger, callback, app) {
13-
try {
14-
const {
15-
getComparisonModelCollection,
16-
getAlterContainersScripts,
17-
getAlterCollectionsScripts,
18-
getAlterViewScripts,
19-
getAlterModelDefinitionsScripts,
20-
} = require('./helpers/alterScriptFromDeltaHelper');
21-
22-
const collection = getComparisonModelCollection(data.collections);
23-
if (!collection) {
24-
throw new Error(
25-
'"comparisonModelCollection" is not found. Alter script can be generated only from Delta model',
26-
);
27-
}
28-
29-
const dbVersion = data.modelData[0]?.dbVersion;
30-
const containersScripts = getAlterContainersScripts(collection);
31-
const collectionsScripts = getAlterCollectionsScripts(collection, app, dbVersion);
32-
const viewScripts = getAlterViewScripts(collection, app);
33-
const modelDefinitionsScripts = getAlterModelDefinitionsScripts(collection, app);
34-
35-
callback(
36-
null,
37-
[...containersScripts, ...collectionsScripts, ...viewScripts, ...modelDefinitionsScripts].join('\n\n'),
38-
);
39-
} catch (e) {
40-
logger.log('error', { message: e.message, stack: e.stack }, 'Cassandra Forward-Engineering Error');
41-
42-
callback({ message: e.message, stack: e.stack });
43-
}
36+
callback(new Error('Forward-Engineering of delta model on container level is not supported'));
4437
},
4538
getDatabases(connectionInfo, logger, callback, app) {
4639
logger.progress({ message: 'Find all databases' });

forward_engineering/config.json

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
11
{
2-
"options": [
2+
"type": "ddl",
3+
"ddlType": "plugin",
4+
"mode": "pgsql",
5+
"fileExtensions": [
36
{
4-
"name": "Create Script",
5-
"keyword": "create",
6-
"type": "ddl",
7-
"ddlType": "plugin",
8-
"mode": "pgsql",
9-
"fileExtensions": [
10-
{
11-
"value": "sql",
12-
"label": "SQL"
13-
}
14-
]
15-
},
16-
{
17-
"name": "Alter Script from Delta model",
18-
"keyword": "alterFromDelta",
19-
"cliOnly": true,
20-
"fileExtensions": [
21-
{
22-
"value": "sql",
23-
"label": "SQL"
24-
}
25-
]
7+
"value": "sql",
8+
"label": "SQL"
269
}
2710
],
11+
"hasUpdateScript": false,
2812
"namePrefix": "PostgreSQL",
2913
"level": {
3014
"container": true,
@@ -39,5 +23,9 @@
3923
"feLevelSelector": {
4024
"container": true,
4125
"model": true
26+
},
27+
"compMode": {
28+
"entity": true,
29+
"container": false
4230
}
4331
}

localization/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"MAIN_MENU___INSERT_FIELD": "Insert Column",
99
"MAIN_MENU___APPEND_FIELD": "Append Column",
1010
"MAIN_MENU___REVERSE_DB_COLLECTIONS": "PostgreSQL schemas...",
11+
"MAIN_MENU___FORWARD_CHANGE_COLLECTIONS": "PostgreSQL Alter Script",
1112
"TOOLBAR___ADD_BUCKET": "Add schema",
1213
"TOOLBAR___ADD_COLLECTION": "Add table",
1314
"TOOLBAR___ADD_VIEW": "Add View",

0 commit comments

Comments
 (0)