From 3b9ed274fb16c6b6e4ee1cabc2ffd0d7efcc7108 Mon Sep 17 00:00:00 2001 From: Vitalii Bedletskyi Date: Tue, 7 Oct 2025 15:27:53 +0300 Subject: [PATCH 1/8] add script generation options config --- forward_engineering/config.json | 413 ++++++++++++++++++++++++++++++++ 1 file changed, 413 insertions(+) diff --git a/forward_engineering/config.json b/forward_engineering/config.json index f945d4d7..fbcffd0a 100644 --- a/forward_engineering/config.json +++ b/forward_engineering/config.json @@ -37,5 +37,418 @@ "name": "Apply Drop Statements", "isDropInStatements": true } + ], + "scriptGenerationOptions": [ + { + "keyword": "primaryKeys", + "label": "FE_SCRIPT_GENERATION_OPTIONS___PRIMARY_KEYS", + "disabled": false, + "value": { + "inline": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "separate": { + "default": false, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "key": "primaryKey", + "valueType": "array" + }, + "defaultValue": { + "primaryKey": [] + } + }, + { + "dependency": { + "key": "primaryKey", + "valueType": "object" + }, + + "defaultValue": { + "primaryKey": {} + } + }, + { + "dependency": { + "type": "or", + "values": [ + { + "key": "primaryKey", + "value": true + }, + { + "key": "compositePrimaryKey", + "value": true + } + ] + }, + "defaultValue": { + "primaryKey": false, + "compositePrimaryKey": false + } + } + ] + }, + { + "keyword": "foreignKeys", + "label": "FE_SCRIPT_GENERATION_OPTIONS___FOREIGN_KEYS", + "disabled": false, + "value": { + "inline": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "separate": { + "default": false, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + } + }, + { + "keyword": "uniqueConstraints", + "label": "FE_SCRIPT_GENERATION_OPTIONS___UNIQUE_KEYS", + "disabled": false, + "value": { + "inline": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "separate": { + "default": false, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "key": "uniqueKey", + "valueType": "array" + }, + "defaultValue": { + "uniqueKey": [] + } + }, + { + "dependency": { + "key": "uniqueKey", + "valueType": "object" + }, + "defaultValue": { + "uniqueKey": {} + } + }, + { + "dependency": { + "type": "or", + "values": [ + { + "key": "unique", + "value": true + }, + { + "key": "compositeUniqueKey", + "value": true + }, + { + "key": "compMode", + "exist": true + } + ] + }, + "defaultValue": { + "unique": false, + "compositeUniqueKey": false + } + } + ] + }, + { + "keyword": "columnNotNullConstraints", + "label": "FE_SCRIPT_GENERATION_OPTIONS___COLUMN_NOT_NULL", + "disabled": false, + "value": { + "inline": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "separate": { + "default": false, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "key": "required", + "value": true + }, + "defaultValue": { + "required": false + } + } + ] + }, + { + "keyword": "checkConstraints", + "label": "FE_SCRIPT_GENERATION_OPTIONS___CHECK_CONSTRAINTS", + "disabled": false, + "value": { + "inline": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "separate": { + "default": false, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "key": "chkConstr", + "valueType": "array" + }, + "defaultValue": { + "chkConstr": [] + } + } + ] + }, + { + "keyword": "columnDefaultValues", + "label": "FE_SCRIPT_GENERATION_OPTIONS___COLUMN_DEFAULT_VALUES", + "disabled": false, + "value": { + "inline": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "separate": { + "default": false, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "key": "default", + "exist": true + }, + "defaultValue": { + "default": "" + } + } + ] + }, + { + "keyword": "schemaComments", + "label": "FE_SCRIPT_GENERATION_OPTIONS___SCHEMA_COMMENTS", + "disabled": false, + "value": { + "inline": { + "default": false, + "disabled": true, + "disabledLabel": "" + }, + "separate": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "key": "type", + "value": "bucket" + }, + "defaultValue": { + "description": "" + } + } + ] + }, + { + "keyword": "tableComments", + "label": "FE_SCRIPT_GENERATION_OPTIONS___TABLE_COMMENTS", + "disabled": false, + "value": { + "inline": { + "default": false, + "disabled": true, + "disabledLabel": "" + }, + "separate": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "type": "and", + "values": [ + { + "key": "collectionName", + "exist": true + }, + { + "key": "description", + "exist": true + } + ] + }, + "defaultValue": { + "description": "" + } + } + ] + }, + { + "keyword": "viewComments", + "label": "FE_SCRIPT_GENERATION_OPTIONS___VIEW_COMMENTS", + "disabled": false, + "value": { + "inline": { + "default": false, + "disabled": true, + "disabledLabel": "" + }, + "separate": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "key": "viewOn", + "exist": true + }, + "defaultValue": { + "description": "" + } + } + ] + }, + { + "keyword": "columnComments", + "label": "FE_SCRIPT_GENERATION_OPTIONS___COLUMN_COMMENTS", + "disabled": false, + "value": { + "inline": { + "default": false, + "disabled": true, + "disabledLabel": "" + }, + "separate": { + "default": true, + "disabled": false, + "disabledLabel": "" + }, + "ignore": { + "default": false, + "disabled": false, + "disabledLabel": "" + } + }, + "adapters": [ + { + "dependency": { + "type": "and", + "values": [ + { + "type": "not", + "values": [ + { + "key": "type", + "value": "bucket" + } + ] + }, + { + "key": "collectionName", + "exist": false + }, + { + "key": "viewOn", + "exist": false + }, + { + "key": "description", + "exist": true + } + ] + }, + "defaultValue": { + "description": "" + } + } + ] + } ] } From f9304af81cdac90d5b52a14d23f4582da371af58 Mon Sep 17 00:00:00 2001 From: Vitalii Bedletskyi Date: Tue, 7 Oct 2025 15:29:09 +0300 Subject: [PATCH 2/8] fix order of constrains in alter statement and fix escape default value logic in alter statement --- .../alterScript/alterScriptFromDeltaHelper.js | 2 +- .../alterScript/alterScriptHelpers/alterEntityHelper.js | 2 +- .../alterScriptHelpers/columnHelpers/defaultValueHelper.js | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/forward_engineering/alterScript/alterScriptFromDeltaHelper.js b/forward_engineering/alterScript/alterScriptFromDeltaHelper.js index 96621219..031242a2 100644 --- a/forward_engineering/alterScript/alterScriptFromDeltaHelper.js +++ b/forward_engineering/alterScript/alterScriptFromDeltaHelper.js @@ -133,9 +133,9 @@ const getAlterCollectionsScriptDtos = ({ ...deleteCollectionScriptDtos, ...modifyCollectionScriptDtos, ...addColumnScriptDtos, - ...modifyCollectionKeysScriptDtos, ...deleteColumnScriptDtos, ...modifyColumnScriptDtos, + ...modifyCollectionKeysScriptDtos, ].filter(Boolean); }; diff --git a/forward_engineering/alterScript/alterScriptHelpers/alterEntityHelper.js b/forward_engineering/alterScript/alterScriptHelpers/alterEntityHelper.js index 6bab4fea..adcaa9b1 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/alterEntityHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/alterEntityHelper.js @@ -290,8 +290,8 @@ const getModifyColumnScriptDtos = ...renameColumnScriptDtos, ...updateTypeScriptDtos, ...modifyNotNullScriptDtos, - ...modifyCommentScriptDtos, ...modifyDefaultColumnValueScriptDtos, + ...modifyCommentScriptDtos, ].filter(Boolean); }; diff --git a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/defaultValueHelper.js b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/defaultValueHelper.js index f90cd732..51c73c27 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/defaultValueHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/defaultValueHelper.js @@ -1,6 +1,7 @@ const { toPairs } = require('lodash'); const { AlterScriptDto } = require('../../types/AlterScriptDto'); -const { getFullTableName, wrapInQuotes, wrapInSingleQuotes } = require('../../../utils/general'); +const { getFullTableName, wrapInQuotes } = require('../../../utils/general'); +const { decorateDefault } = require('../../../ddlProvider/ddlHelpers/columnDefinitionHelper'); const assignTemplates = require('../../../utils/assignTemplates'); const templates = require('../../../ddlProvider/templates'); @@ -35,10 +36,12 @@ const getUpdatedDefaultColumnValueScriptDtos = ({ collection }) => }) .map(([columnName, jsonSchema]) => { const newDefaultValue = jsonSchema.default; + const type = jsonSchema.mode || jsonSchema.childType || jsonSchema.type; + const isArrayType = Array.isArray(jsonSchema.array_type) && jsonSchema.array_type.length > 0; const scriptGenerationConfig = { tableName: getFullTableName(collection), columnName: wrapInQuotes(columnName), - defaultValue: wrapInSingleQuotes({ name: newDefaultValue }), + defaultValue: decorateDefault(type, newDefaultValue, isArrayType), }; return updateColumnDefaultValue(scriptGenerationConfig); }) From 4fbb3c6dfdecfb63058d8d048c0ee71796c959e4 Mon Sep 17 00:00:00 2001 From: Vitalii Bedletskyi Date: Tue, 7 Oct 2025 15:29:37 +0300 Subject: [PATCH 3/8] add browser support --- api/fe.js | 11 +++ esbuild.package.js | 1 + forward_engineering/api.js | 91 +++---------------- forward_engineering/api/applyToInstance.js | 20 ++++ .../api/generateContainerScript.js | 16 ++++ forward_engineering/api/generateScript.js | 16 ++++ forward_engineering/api/generateViewScript.js | 7 ++ forward_engineering/api/getDatabases.js | 11 +++ forward_engineering/api/isDropInStatements.js | 22 +++++ forward_engineering/api/testConnection.js | 9 ++ 10 files changed, 127 insertions(+), 77 deletions(-) create mode 100644 api/fe.js create mode 100644 forward_engineering/api/applyToInstance.js create mode 100644 forward_engineering/api/generateContainerScript.js create mode 100644 forward_engineering/api/generateScript.js create mode 100644 forward_engineering/api/generateViewScript.js create mode 100644 forward_engineering/api/getDatabases.js create mode 100644 forward_engineering/api/isDropInStatements.js create mode 100644 forward_engineering/api/testConnection.js diff --git a/api/fe.js b/api/fe.js new file mode 100644 index 00000000..c61aabcf --- /dev/null +++ b/api/fe.js @@ -0,0 +1,11 @@ +const { generateScript } = require('../forward_engineering/api/generateScript'); +const { generateViewScript } = require('../forward_engineering/api/generateViewScript'); +const { generateContainerScript } = require('../forward_engineering/api/generateContainerScript'); +const { isDropInStatements } = require('../forward_engineering/api/isDropInStatements'); + +module.exports = { + generateScript, + generateViewScript, + generateContainerScript, + isDropInStatements, +}; diff --git a/esbuild.package.js b/esbuild.package.js index 953f56f8..4c470516 100644 --- a/esbuild.package.js +++ b/esbuild.package.js @@ -13,6 +13,7 @@ esbuild .build({ entryPoints: [ path.resolve(__dirname, 'forward_engineering', 'api.js'), + path.resolve(__dirname, 'api', 'fe.js'), path.resolve(__dirname, 'forward_engineering', 'ddlProvider.js'), path.resolve(__dirname, 'forward_engineering', 'dbtProvider.js'), path.resolve(__dirname, 'reverse_engineering', 'api.js'), diff --git a/forward_engineering/api.js b/forward_engineering/api.js index 8261c790..dd704df2 100644 --- a/forward_engineering/api.js +++ b/forward_engineering/api.js @@ -1,80 +1,17 @@ -const _ = require('lodash'); -const reApi = require('../reverse_engineering/api'); -const { createLogger } = require('../reverse_engineering/helpers/loggerHelper'); -const applyToInstanceHelper = require('./applyToInstanceHelper'); -const { - buildEntityLevelAlterScript, - buildContainerLevelAlterScript, - doesContainerLevelAlterScriptContainDropStatements, - doesEntityLevelAlterScriptContainDropStatements, -} = require('./alterScript/alterScriptBuilder'); +const { generateScript } = require('./api/generateScript'); +const { generateViewScript } = require('./api/generateViewScript'); +const { generateContainerScript } = require('./api/generateContainerScript'); +const { getDatabases } = require('./api/getDatabases'); +const { applyToInstance } = require('./api/applyToInstance'); +const { testConnection } = require('./api/testConnection'); +const { isDropInStatements } = require('./api/isDropInStatements'); module.exports = { - generateScript(data, logger, callback, app) { - try { - const script = buildEntityLevelAlterScript(data, app); - callback(null, script); - } catch (error) { - logger.log('error', { message: error.message, stack: error.stack }, 'PostgreSQL Forward-Engineering Error'); - - callback({ message: error.message, stack: error.stack }); - } - }, - - 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 script = buildContainerLevelAlterScript(data, app); - callback(null, script); - } catch (error) { - logger.log('error', { message: error.message, stack: error.stack }, 'PostgreSQL Forward-Engineering Error'); - - callback({ message: error.message, stack: error.stack }); - } - }, - - getDatabases(connectionInfo, logger, callback, app) { - logger.progress({ message: 'Find all databases' }); - - reApi.getDatabases(connectionInfo, logger, callback, app); - }, - - applyToInstance(connectionInfo, logger, callback, app) { - logger.clear(); - logger.log( - 'info', - _.omit(connectionInfo, 'script', 'containerData'), - 'connectionInfo', - connectionInfo.hiddenKeys, - ); - - const postgresLogger = createLogger({ - title: 'Apply to instance', - hiddenKeys: connectionInfo.hiddenKeys, - logger, - }); - - applyToInstanceHelper.applyToInstance(connectionInfo, postgresLogger, app).then(callback, callback); - }, - - testConnection(connectionInfo, logger, callback, app) { - reApi.testConnection(connectionInfo, logger, callback, app).then(callback, callback); - }, - - isDropInStatements(data, logger, callback, app) { - try { - if (data.level === 'container') { - const containsDropStatements = doesContainerLevelAlterScriptContainDropStatements(data, app); - callback(null, containsDropStatements); - } else { - const containsDropStatements = doesEntityLevelAlterScriptContainDropStatements(data, app); - callback(null, containsDropStatements); - } - } catch (e) { - callback({ message: e.message, stack: e.stack }); - } - }, + generateScript, + generateViewScript, + generateContainerScript, + getDatabases, + applyToInstance, + testConnection, + isDropInStatements, }; diff --git a/forward_engineering/api/applyToInstance.js b/forward_engineering/api/applyToInstance.js new file mode 100644 index 00000000..97f935f4 --- /dev/null +++ b/forward_engineering/api/applyToInstance.js @@ -0,0 +1,20 @@ +const _ = require('lodash'); +const { createLogger } = require('../../reverse_engineering/helpers/loggerHelper'); +const applyToInstanceHelper = require('../applyToInstanceHelper'); + +function applyToInstance(connectionInfo, logger, callback, app) { + logger.clear(); + logger.log('info', _.omit(connectionInfo, 'script', 'containerData'), 'connectionInfo', connectionInfo.hiddenKeys); + + const postgresLogger = createLogger({ + title: 'Apply to instance', + hiddenKeys: connectionInfo.hiddenKeys, + logger, + }); + + applyToInstanceHelper.applyToInstance(connectionInfo, postgresLogger, app).then(callback, callback); +} + +module.exports = { + applyToInstance, +}; diff --git a/forward_engineering/api/generateContainerScript.js b/forward_engineering/api/generateContainerScript.js new file mode 100644 index 00000000..ffde45ed --- /dev/null +++ b/forward_engineering/api/generateContainerScript.js @@ -0,0 +1,16 @@ +const { buildContainerLevelAlterScript } = require('../alterScript/alterScriptBuilder'); + +function generateContainerScript(data, logger, callback, app) { + try { + const script = buildContainerLevelAlterScript(data, app); + callback(null, script); + } catch (error) { + logger.log('error', { message: error.message, stack: error.stack }, 'PostgreSQL Forward-Engineering Error'); + + callback({ message: error.message, stack: error.stack }); + } +} + +module.exports = { + generateContainerScript, +}; diff --git a/forward_engineering/api/generateScript.js b/forward_engineering/api/generateScript.js new file mode 100644 index 00000000..5aa4e88d --- /dev/null +++ b/forward_engineering/api/generateScript.js @@ -0,0 +1,16 @@ +const { buildEntityLevelAlterScript } = require('../alterScript/alterScriptBuilder'); + +function generateScript(data, logger, callback, app) { + try { + const script = buildEntityLevelAlterScript(data, app); + callback(null, script); + } catch (error) { + logger.log('error', { message: error.message, stack: error.stack }, 'PostgreSQL Forward-Engineering Error'); + + callback({ message: error.message, stack: error.stack }); + } +} + +module.exports = { + generateScript, +}; diff --git a/forward_engineering/api/generateViewScript.js b/forward_engineering/api/generateViewScript.js new file mode 100644 index 00000000..ddb2b388 --- /dev/null +++ b/forward_engineering/api/generateViewScript.js @@ -0,0 +1,7 @@ +function generateViewScript(data, logger, callback, app) { + callback(new Error('Forward-Engineering of delta model on view level is not supported')); +} + +module.exports = { + generateViewScript, +}; diff --git a/forward_engineering/api/getDatabases.js b/forward_engineering/api/getDatabases.js new file mode 100644 index 00000000..169b3be5 --- /dev/null +++ b/forward_engineering/api/getDatabases.js @@ -0,0 +1,11 @@ +const reApi = require('../../reverse_engineering/api'); + +function getDatabases(connectionInfo, logger, callback, app) { + logger.progress({ message: 'Find all databases' }); + + reApi.getDatabases(connectionInfo, logger, callback, app); +} + +module.exports = { + getDatabases, +}; diff --git a/forward_engineering/api/isDropInStatements.js b/forward_engineering/api/isDropInStatements.js new file mode 100644 index 00000000..1d7fd537 --- /dev/null +++ b/forward_engineering/api/isDropInStatements.js @@ -0,0 +1,22 @@ +const { + doesContainerLevelAlterScriptContainDropStatements, + doesEntityLevelAlterScriptContainDropStatements, +} = require('../alterScript/alterScriptBuilder'); + +function isDropInStatements(data, logger, callback, app) { + try { + if (data.level === 'container') { + const containsDropStatements = doesContainerLevelAlterScriptContainDropStatements(data, app); + callback(null, containsDropStatements); + } else { + const containsDropStatements = doesEntityLevelAlterScriptContainDropStatements(data, app); + callback(null, containsDropStatements); + } + } catch (e) { + callback({ message: e.message, stack: e.stack }); + } +} + +module.exports = { + isDropInStatements, +}; diff --git a/forward_engineering/api/testConnection.js b/forward_engineering/api/testConnection.js new file mode 100644 index 00000000..f45e90c1 --- /dev/null +++ b/forward_engineering/api/testConnection.js @@ -0,0 +1,9 @@ +const reApi = require('../../reverse_engineering/api'); + +function testConnection(connectionInfo, logger, callback, app) { + reApi.testConnection(connectionInfo, logger, callback, app).then(callback, callback); +} + +module.exports = { + testConnection, +}; From cf8c8790b491da7a15d9cf9cfca71e4a7edd2af4 Mon Sep 17 00:00:00 2001 From: Vitalii Bedletskyi Date: Tue, 7 Oct 2025 15:45:57 +0300 Subject: [PATCH 4/8] delete unnecessary .then statement --- forward_engineering/api/testConnection.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/forward_engineering/api/testConnection.js b/forward_engineering/api/testConnection.js index f45e90c1..e5d00b78 100644 --- a/forward_engineering/api/testConnection.js +++ b/forward_engineering/api/testConnection.js @@ -1,7 +1,7 @@ const reApi = require('../../reverse_engineering/api'); -function testConnection(connectionInfo, logger, callback, app) { - reApi.testConnection(connectionInfo, logger, callback, app).then(callback, callback); +async function testConnection(connectionInfo, logger, callback, app) { + await reApi.testConnection(connectionInfo, logger, callback, app); } module.exports = { From 4ef91de566beb29f8b5b737d268e6ddb780bf737 Mon Sep 17 00:00:00 2001 From: Vitalii Bedletskyi Date: Tue, 7 Oct 2025 16:33:38 +0300 Subject: [PATCH 5/8] adjust column types whose default values need to be wrapped with escape characters --- .../ddlProvider/ddlHelpers/columnDefinitionHelper.js | 12 ++++++++---- .../ddlProvider/ddlHelpers/typeHelper.js | 6 ++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/forward_engineering/ddlProvider/ddlHelpers/columnDefinitionHelper.js b/forward_engineering/ddlProvider/ddlHelpers/columnDefinitionHelper.js index adb130e3..7fcd279c 100644 --- a/forward_engineering/ddlProvider/ddlHelpers/columnDefinitionHelper.js +++ b/forward_engineering/ddlProvider/ddlHelpers/columnDefinitionHelper.js @@ -2,7 +2,7 @@ const _ = require('lodash'); const { commentIfDeactivated, wrapInQuotes, wrapComment } = require('../../utils/general'); const assignTemplates = require('../../utils/assignTemplates'); const templates = require('../templates'); -const { isVector, isString, isDateTime } = require('./typeHelper'); +const { isVector, isString, isDateTime, isUUID, isInet } = require('./typeHelper'); const addLength = (type, length) => { return `${type}(${length})`; @@ -82,11 +82,15 @@ const decorateType = (type, columnDefinition) => { const decorateDefault = (type, defaultValue, isArrayType) => { const constantsValues = ['current_timestamp', 'current_user', 'null']; - if ((isString(type) || isDateTime(type)) && !constantsValues.includes(_.toLower(defaultValue)) && !isArrayType) { - return wrapComment(defaultValue); - } else { + + const isConstantValue = constantsValues.includes(_.toLower(defaultValue)); + const isQuotableType = isString(type) || isDateTime(type) || isUUID(type) || isInet(type); + + if (!isQuotableType || isConstantValue || isArrayType) { return defaultValue; } + + return wrapComment(defaultValue); }; const getColumnComments = (tableName, columnDefinitions) => { diff --git a/forward_engineering/ddlProvider/ddlHelpers/typeHelper.js b/forward_engineering/ddlProvider/ddlHelpers/typeHelper.js index f487bb88..61c125f3 100644 --- a/forward_engineering/ddlProvider/ddlHelpers/typeHelper.js +++ b/forward_engineering/ddlProvider/ddlHelpers/typeHelper.js @@ -4,8 +4,14 @@ const isDateTime = type => ['date', 'time', 'timestamp', 'interval'].includes(ty const isVector = type => ['vector', 'halfvec', 'sparsevec'].includes(type); +const isInet = type => ['inet', 'cidr', 'macaddr', 'macaddr8'].includes(type); + +const isUUID = type => type === 'uuid'; + module.exports = { isString, isDateTime, isVector, + isInet, + isUUID, }; From 0e9d055e4e59a8b5373a3bb23915d49e673e9510 Mon Sep 17 00:00:00 2001 From: Vitalii Bedletskyi Date: Wed, 8 Oct 2025 22:29:00 +0300 Subject: [PATCH 6/8] fix missing COMMENT ON statements for UDT --- forward_engineering/config.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/forward_engineering/config.json b/forward_engineering/config.json index fbcffd0a..cf9c73ee 100644 --- a/forward_engineering/config.json +++ b/forward_engineering/config.json @@ -427,6 +427,12 @@ { "key": "type", "value": "bucket" + }, + { + "level": "parent", + "key": "type", + "value": "definitions", + "inDepthParentSearch": true } ] }, From b289dd8e91e67b2f6b50208ece5897e96850cb3c Mon Sep 17 00:00:00 2001 From: Vitalii Bedletskyi Date: Wed, 8 Oct 2025 22:46:54 +0300 Subject: [PATCH 7/8] HCK-13009: comment related alter statement to deactivated objects --- .../alterScript/alterScriptFromDeltaHelper.js | 14 ++++++-- .../alterContainerHelper.js | 10 +++--- .../alterScriptHelpers/alterEntityHelper.js | 34 +++++++++++++----- .../alterScriptHelpers/alterUdtHelper.js | 23 +++++++----- .../columnHelpers/alterTypeHelper.js | 15 ++++++-- .../columnHelpers/commentsHelper.js | 21 ++++++++--- .../columnHelpers/defaultValueHelper.js | 35 +++++++++++++------ .../columnHelpers/nonNullConstraintHelper.js | 24 ++++++++++--- .../columnHelpers/renameColumnHelper.js | 16 +++++++-- .../containerHelpers/commentsHelper.js | 8 +++-- .../containerHelpers/sequencesHelper.js | 15 ++++---- .../entityHelpers/checkConstraintHelper.js | 15 ++++++-- .../entityHelpers/commentsHelper.js | 17 +++++++-- .../entityHelpers/primaryKeyHelper.js | 22 +++++++++--- .../entityHelpers/uniqueKeyHelper.js | 22 +++++++++--- .../viewHelpers/commentsHelper.js | 19 ++++++++-- .../ddlHelpers/constraintsHelper.js | 2 +- forward_engineering/utils/general.js | 12 +++++++ 18 files changed, 250 insertions(+), 74 deletions(-) diff --git a/forward_engineering/alterScript/alterScriptFromDeltaHelper.js b/forward_engineering/alterScript/alterScriptFromDeltaHelper.js index 031242a2..b2dd7306 100644 --- a/forward_engineering/alterScript/alterScriptFromDeltaHelper.js +++ b/forward_engineering/alterScript/alterScriptFromDeltaHelper.js @@ -38,6 +38,7 @@ const { getDeleteContainerSequencesScriptDtos, getAddContainerSequencesScriptDtos, } = require('./alterScriptHelpers/containerHelpers/sequencesHelper'); +const { isObjectInDeltaModelActivated } = require('../utils/general'); /** * @param dto {{ @@ -53,12 +54,20 @@ const getAlterContainersScriptDtos = ({ collection }) => { const addContainersScriptDtos = [] .concat(addedContainers) .filter(Boolean) - .map(container => getAddContainerScriptDto(Object.keys(container.properties)[0])); + .map(container => { + const [containerName, containerData] = Object.entries(container.properties)[0]; + const isActivated = isObjectInDeltaModelActivated(containerData); + return getAddContainerScriptDto(containerName, isActivated); + }); const deleteContainersScriptDtos = [] .concat(deletedContainers) .filter(Boolean) - .map(container => getDeleteContainerScriptDto(Object.keys(container.properties)[0])); + .map(container => { + const [containerName, containerData] = Object.entries(container.properties)[0]; + const isActivated = isObjectInDeltaModelActivated(containerData); + return getDeleteContainerScriptDto(containerName, isActivated); + }); const modifyContainersScriptDtos = [] .concat(modifiedContainers) @@ -189,6 +198,7 @@ const getAlterModelDefinitionsScriptDtos = ({ internalDefinitions, externalDefinitions, }) => { + debugger; const createUdtScriptDtos = [] .concat(collection.properties?.modelDefinitions?.properties?.added?.items) .filter(Boolean) diff --git a/forward_engineering/alterScript/alterScriptHelpers/alterContainerHelper.js b/forward_engineering/alterScript/alterScriptHelpers/alterContainerHelper.js index 77c58e0f..22bc5897 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/alterContainerHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/alterContainerHelper.js @@ -29,20 +29,22 @@ const dropSchema = schemaName => { /** * @param {string} containerName + * @param {boolean} isActivated * @return {AlterScriptDto | undefined} * */ -const getAddContainerScriptDto = containerName => { +const getAddContainerScriptDto = (containerName, isActivated = true) => { const script = createSchemaOnly(wrapInQuotes(containerName)); - return AlterScriptDto.getInstance([script], true, false); + return AlterScriptDto.getInstance([script], isActivated, false); }; /** * @param {string} containerName + * @param {boolean} isActivated * @return {AlterScriptDto | undefined} * */ -const getDeleteContainerScriptDto = containerName => { +const getDeleteContainerScriptDto = (containerName, isActivated = true) => { const script = dropSchema(wrapInQuotes(containerName)); - return AlterScriptDto.getInstance([script], true, true); + return AlterScriptDto.getInstance([script], isActivated, true); }; /** diff --git a/forward_engineering/alterScript/alterScriptHelpers/alterEntityHelper.js b/forward_engineering/alterScript/alterScriptHelpers/alterEntityHelper.js index adcaa9b1..899767d1 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/alterEntityHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/alterEntityHelper.js @@ -15,7 +15,14 @@ const { getAdditionalDataForDdlProvider, } = require('./entityHelpers/indexesHelper'); const { getModifiedDefaultColumnValueScriptDtos } = require('./columnHelpers/defaultValueHelper'); -const { getEntityName, getFullTableName, getNamePrefixedWithSchemaName, wrapInQuotes } = require('../../utils/general'); +const { + getEntityName, + getFullTableName, + getNamePrefixedWithSchemaName, + wrapInQuotes, + isParentContainerActivated, + isObjectInDeltaModelActivated, +} = require('../../utils/general'); /** * @return {(collection: AlterCollectionDto) => AlterScriptDto | undefined} @@ -124,6 +131,9 @@ const getAddColumnsByConditionScriptDtos = const fullName = getNamePrefixedWithSchemaName(tableName, schemaName); const schemaData = { schemaName, dbVersion }; + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isObjectInDeltaModelActivated(collection); + const scripts = _.toPairs(collection.properties) .filter(([name, jsonSchema]) => predicate([name, jsonSchema])) .map(([name, jsonSchema]) => { @@ -134,7 +144,7 @@ const getAddColumnsByConditionScriptDtos = externalDefinitions, }); - return createColumnDefinitionBySchema({ + const columnDefinition = createColumnDefinitionBySchema({ name, jsonSchema, parentJsonSchema: collectionSchema, @@ -142,10 +152,14 @@ const getAddColumnsByConditionScriptDtos = schemaData, definitionJsonSchema, }); + const isActivated = isContainerActivated && isCollectionActivated && jsonSchema.isActivated; + return { columnDefinition, isActivated }; }) - .map(ddlProvider.convertColumnDefinition) - .map(columnDefinition => ddlProvider.addColumn(fullName, columnDefinition)) - .map(addColumnScript => AlterScriptDto.getInstance([addColumnScript], true, false)); + .map(({ columnDefinition, isActivated }) => ({ + script: ddlProvider.addColumn(fullName, ddlProvider.convertColumnDefinition(columnDefinition)), + isActivated, + })) + .map(({ script, isActivated }) => AlterScriptDto.getInstance([script], isActivated, false)); return scripts.filter(Boolean); }; @@ -204,13 +218,17 @@ const getDeleteColumnsByConditionScriptDtos = app => (collection, predicate) => const schemaName = collectionSchema.compMod?.keyspaceName; const fullTableName = getNamePrefixedWithSchemaName(tableName, schemaName); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isObjectInDeltaModelActivated(collection); + return _.toPairs(collection.properties) .filter(([name, jsonSchema]) => predicate([name, jsonSchema])) - .map(([name]) => { + .map(([name, jsonSchema]) => { const columnNameForDDL = wrapInQuotes(name); - return ddlProvider.dropColumn(fullTableName, columnNameForDDL); + const isActivated = isContainerActivated && isCollectionActivated && jsonSchema.isActivated; + return { script: ddlProvider.dropColumn(fullTableName, columnNameForDDL), isActivated }; }) - .map(dropColumnScript => AlterScriptDto.getInstance([dropColumnScript], true, true)) + .map(({ script, isActivated }) => AlterScriptDto.getInstance([script], isActivated, true)) .filter(Boolean); }; diff --git a/forward_engineering/alterScript/alterScriptHelpers/alterUdtHelper.js b/forward_engineering/alterScript/alterScriptHelpers/alterUdtHelper.js index af43cd80..815149e7 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/alterUdtHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/alterUdtHelper.js @@ -1,6 +1,11 @@ const _ = require('lodash'); const { AlterScriptDto } = require('../types/AlterScriptDto'); -const { getUdtName, wrapInQuotes, checkFieldPropertiesChanged } = require('../../utils/general'); +const { + getUdtName, + wrapInQuotes, + checkFieldPropertiesChanged, + isObjectInDeltaModelActivated, +} = require('../../utils/general'); /** * @return {(jsonSchema: Object) => AlterScriptDto | undefined} @@ -44,7 +49,7 @@ const getCreateUdtScriptDto = const udt = { ...updatedUdt, properties: columnDefinitions }; const script = ddlProvider.createUdt(udt); - return AlterScriptDto.getInstance([script], true, false); + return AlterScriptDto.getInstance([script], jsonSchema.isActivated, false); }; /** @@ -56,10 +61,10 @@ const getDeleteUdtScriptDto = app => udt => { const ddlUdtName = wrapInQuotes(getUdtName(udt)); if (udt.type === 'domain') { const script = ddlProvider.dropDomain(ddlUdtName); - return AlterScriptDto.getInstance([script], true, true); + return AlterScriptDto.getInstance([script], udt.isActivated, true); } else { const script = ddlProvider.dropType(ddlUdtName); - return AlterScriptDto.getInstance([script], true, true); + return AlterScriptDto.getInstance([script], udt.isActivated, true); } }; @@ -97,7 +102,7 @@ const getAddColumnToTypeScriptDtos = }) .map(ddlProvider.convertColumnDefinition) .map(columnDefinition => ddlProvider.alterTypeAddAttribute(fullName, columnDefinition)) - .map(script => AlterScriptDto.getInstance([script], true, false)) + .map(script => AlterScriptDto.getInstance([script], udt.isActivated, false)) .filter(Boolean); }; @@ -108,11 +113,12 @@ const getDeleteColumnFromTypeScriptDtos = app => udt => { const ddlProvider = require('../../ddlProvider/ddlProvider')(null, null, app); const fullName = wrapInQuotes(udt.code || udt.name); + const isActivated = isObjectInDeltaModelActivated(udt); return _.toPairs(udt.properties) .filter(([name, jsonSchema]) => !jsonSchema.compMod) .map(([name]) => ddlProvider.alterTypeDropAttribute(fullName, wrapInQuotes(name))) - .map(script => AlterScriptDto.getInstance([script], true, true)) + .map(script => AlterScriptDto.getInstance([script], isActivated, true)) .filter(Boolean); }; @@ -123,6 +129,7 @@ const getModifyColumnOfTypeScriptDtos = app => udt => { const ddlProvider = require('../../ddlProvider/ddlProvider')(null, null, app); const fullName = wrapInQuotes(udt.code || udt.name); + const isActivated = isObjectInDeltaModelActivated(udt); const renameColumnScripts = _.values(udt.properties) .filter(jsonSchema => checkFieldPropertiesChanged(jsonSchema.compMod, ['name'])) @@ -131,7 +138,7 @@ const getModifyColumnOfTypeScriptDtos = app => udt => { const newAttributeDDLName = wrapInQuotes(jsonSchema.compMod.newField.name); return ddlProvider.alterTypeRenameAttribute(fullName, oldAttributeDDLName, newAttributeDDLName); }) - .map(script => AlterScriptDto.getInstance([script], true, false)); + .map(script => AlterScriptDto.getInstance([script], isActivated, false)); const changeTypeScripts = _.toPairs(udt.properties) .filter(([name, jsonSchema]) => checkFieldPropertiesChanged(jsonSchema.compMod, ['type', 'mode'])) @@ -140,7 +147,7 @@ const getModifyColumnOfTypeScriptDtos = app => udt => { const newDataType = jsonSchema.compMod.newField.mode || jsonSchema.compMod.newField.type; return ddlProvider.alterTypeChangeAttributeType(fullName, attributeDDLName, newDataType); }) - .map(script => AlterScriptDto.getInstance([script], true, false)); + .map(script => AlterScriptDto.getInstance([script], isActivated, false)); return [...renameColumnScripts, ...changeTypeScripts].filter(Boolean); }; diff --git a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/alterTypeHelper.js b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/alterTypeHelper.js index ead25ee1..767e71cc 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/alterTypeHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/alterTypeHelper.js @@ -1,6 +1,12 @@ const _ = require('lodash'); const { AlterScriptDto } = require('../../types/AlterScriptDto'); -const { checkFieldPropertiesChanged, getFullTableName, wrapInQuotes } = require('../../../utils/general'); +const { + checkFieldPropertiesChanged, + getFullTableName, + wrapInQuotes, + isObjectInDeltaModelActivated, + isParentContainerActivated, +} = require('../../../utils/general'); const assignTemplates = require('../../../utils/assignTemplates'); const templates = require('../../../ddlProvider/templates'); @@ -63,6 +69,8 @@ const hasPrecisionOrScaleChanged = (collection, oldFieldName, currentJsonSchema) * */ const getUpdateTypesScriptDtos = collection => { const fullTableName = getFullTableName(collection); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isObjectInDeltaModelActivated(collection); return _.toPairs(collection.properties) .filter(([name, jsonSchema]) => { @@ -79,9 +87,10 @@ const getUpdateTypesScriptDtos = collection => { const typeName = jsonSchema.compMod.newField.mode || jsonSchema.compMod.newField.type; const columnName = wrapInQuotes(name); const typeConfig = _.pick(jsonSchema, ['length', 'precision', 'scale']); - return alterColumnType(fullTableName, columnName, typeName, typeConfig); + const isActivated = isContainerActivated && isCollectionActivated && jsonSchema.isActivated; + return { script: alterColumnType(fullTableName, columnName, typeName, typeConfig), isActivated }; }) - .map(script => AlterScriptDto.getInstance([script], true, false)); + .map(({ script, isActivated }) => AlterScriptDto.getInstance([script], isActivated, false)); }; module.exports = { diff --git a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/commentsHelper.js b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/commentsHelper.js index 952402d8..68b756e7 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/commentsHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/commentsHelper.js @@ -1,6 +1,11 @@ const _ = require('lodash'); const { AlterScriptDto } = require('../../types/AlterScriptDto'); -const { getFullColumnName, wrapComment } = require('../../../utils/general'); +const { + getFullColumnName, + wrapComment, + isObjectInDeltaModelActivated, + isParentContainerActivated, +} = require('../../../utils/general'); const assignTemplates = require('../../../utils/assignTemplates'); const templates = require('../../../ddlProvider/templates'); @@ -22,6 +27,8 @@ const updateColumnComment = (columnName, comment) => { * @return {AlterScriptDto[]} * */ const getUpdatedCommentOnColumnScriptDtos = collection => { + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isObjectInDeltaModelActivated(collection); return _.toPairs(collection.properties) .filter(([name, jsonSchema]) => { const newComment = jsonSchema.description; @@ -33,9 +40,10 @@ const getUpdatedCommentOnColumnScriptDtos = collection => { const newComment = jsonSchema.description; const ddlComment = wrapComment(newComment); const columnName = getFullColumnName(collection, name); - return updateColumnComment(columnName, ddlComment); + const isActivated = isContainerActivated && isCollectionActivated && jsonSchema.isActivated; + return { script: updateColumnComment(columnName, ddlComment), isActivated }; }) - .map(script => AlterScriptDto.getInstance([script], true, false)); + .map(({ script, isActivated }) => AlterScriptDto.getInstance([script], isActivated, false)); }; /** @@ -55,6 +63,8 @@ const dropColumnComment = columnName => { * @return {AlterScriptDto[]} * */ const getDeletedCommentOnColumnScriptDtos = collection => { + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isObjectInDeltaModelActivated(collection); return _.toPairs(collection.properties) .filter(([name, jsonSchema]) => { const newComment = jsonSchema.description; @@ -64,9 +74,10 @@ const getDeletedCommentOnColumnScriptDtos = collection => { }) .map(([name, jsonSchema]) => { const columnName = getFullColumnName(collection, name); - return dropColumnComment(columnName); + const isActivated = isContainerActivated && isCollectionActivated && jsonSchema.isActivated; + return { script: dropColumnComment(columnName), isActivated }; }) - .map(script => AlterScriptDto.getInstance([script], true, true)); + .map(({ script, isActivated }) => AlterScriptDto.getInstance([script], isActivated, true)); }; /** diff --git a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/defaultValueHelper.js b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/defaultValueHelper.js index 51c73c27..bcf04d4d 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/defaultValueHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/defaultValueHelper.js @@ -1,6 +1,11 @@ const { toPairs } = require('lodash'); const { AlterScriptDto } = require('../../types/AlterScriptDto'); -const { getFullTableName, wrapInQuotes } = require('../../../utils/general'); +const { + getFullTableName, + wrapInQuotes, + isObjectInDeltaModelActivated, + isParentContainerActivated, +} = require('../../../utils/general'); const { decorateDefault } = require('../../../ddlProvider/ddlHelpers/columnDefinitionHelper'); const assignTemplates = require('../../../utils/assignTemplates'); const templates = require('../../../ddlProvider/templates'); @@ -26,8 +31,11 @@ const updateColumnDefaultValue = ({ tableName, columnName, defaultValue }) => { * @param {Object} props.collection * @returns { Array } * */ -const getUpdatedDefaultColumnValueScriptDtos = ({ collection }) => - toPairs(collection.properties) +const getUpdatedDefaultColumnValueScriptDtos = ({ collection }) => { + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isObjectInDeltaModelActivated(collection); + + return toPairs(collection.properties) .filter(([_name, jsonSchema]) => { const newDefault = jsonSchema.default; const oldName = jsonSchema.compMod.oldField.name; @@ -43,10 +51,12 @@ const getUpdatedDefaultColumnValueScriptDtos = ({ collection }) => columnName: wrapInQuotes(columnName), defaultValue: decorateDefault(type, newDefaultValue, isArrayType), }; - return updateColumnDefaultValue(scriptGenerationConfig); + const isActivated = isContainerActivated && isCollectionActivated && jsonSchema.isActivated; + return { script: updateColumnDefaultValue(scriptGenerationConfig), isActivated }; }) - .map(script => AlterScriptDto.getInstance([script], true, false)) + .map(({ script, isActivated }) => AlterScriptDto.getInstance([script], isActivated, false)) .filter(Boolean); +}; /** * @param {Object} props @@ -67,8 +77,11 @@ const dropColumnDefaultValue = ({ tableName, columnName }) => { * @param {Object} props.collection * @returns { Array } * */ -const getDeletedDefaultColumnValueScriptDtos = ({ collection }) => - toPairs(collection.properties) +const getDeletedDefaultColumnValueScriptDtos = ({ collection }) => { + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isObjectInDeltaModelActivated(collection); + + return toPairs(collection.properties) .filter(([_name, jsonSchema]) => { const newDefault = jsonSchema.default; const oldName = jsonSchema.compMod.oldField.name; @@ -77,15 +90,17 @@ const getDeletedDefaultColumnValueScriptDtos = ({ collection }) => const hasNewValue = newDefault !== undefined; return hasPrevValue && !hasNewValue; }) - .map(([columnName]) => { + .map(([columnName, jsonSchema]) => { const scriptGenerationConfig = { tableName: getFullTableName(collection), columnName: wrapInQuotes(columnName), }; - return dropColumnDefaultValue(scriptGenerationConfig); + const isActivated = isContainerActivated && isCollectionActivated && jsonSchema.isActivated; + return { script: dropColumnDefaultValue(scriptGenerationConfig), isActivated }; }) - .map(script => AlterScriptDto.getInstance([script], true, true)) + .map(({ script, isActivated }) => AlterScriptDto.getInstance([script], isActivated, true)) .filter(Boolean); +}; /** * @param {Object} props diff --git a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/nonNullConstraintHelper.js b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/nonNullConstraintHelper.js index e6f21536..d2d39d1a 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/nonNullConstraintHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/nonNullConstraintHelper.js @@ -1,6 +1,11 @@ const _ = require('lodash'); const { AlterScriptDto } = require('../../types/AlterScriptDto'); -const { getFullTableName, wrapInQuotes } = require('../../../utils/general'); +const { + getFullTableName, + wrapInQuotes, + isObjectInDeltaModelActivated, + isParentContainerActivated, +} = require('../../../utils/general'); const assignTemplates = require('../../../utils/assignTemplates'); const templates = require('../../../ddlProvider/templates'); @@ -35,6 +40,9 @@ const dropNotNullConstraint = (tableName, columnName) => { const getModifyNonNullColumnsScriptDtos = collection => { const fullTableName = getFullTableName(collection); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isObjectInDeltaModelActivated(collection); + const currentRequiredColumnNames = collection.required || []; const previousRequiredColumnNames = collection.role.required || []; @@ -48,8 +56,11 @@ const getModifyNonNullColumnsScriptDtos = collection => { const shouldAddForNewName = columnNamesToAddNotNullConstraint.includes(name); return shouldAddForNewName && !shouldRemoveForOldName; }) - .map(([columnName]) => setNotNullConstraint(fullTableName, wrapInQuotes(columnName))) - .map(script => AlterScriptDto.getInstance([script], true, false)); + .map(([columnName, jsonSchema]) => { + const isActivated = isContainerActivated && isCollectionActivated && jsonSchema.isActivated; + return { script: setNotNullConstraint(fullTableName, wrapInQuotes(columnName)), isActivated }; + }) + .map(({ script, isActivated }) => AlterScriptDto.getInstance([script], isActivated, false)); const removeNotNullConstraint = _.toPairs(collection.properties) .filter(([name, jsonSchema]) => { @@ -58,8 +69,11 @@ const getModifyNonNullColumnsScriptDtos = collection => { const shouldAddForNewName = columnNamesToAddNotNullConstraint.includes(name); return shouldRemoveForOldName && !shouldAddForNewName; }) - .map(([name]) => dropNotNullConstraint(fullTableName, wrapInQuotes(name))) - .map(script => AlterScriptDto.getInstance([script], true, true)); + .map(([name, jsonSchema]) => { + const isActivated = isContainerActivated && isCollectionActivated && jsonSchema.isActivated; + return { script: dropNotNullConstraint(fullTableName, wrapInQuotes(name)), isActivated }; + }) + .map(({ script, isActivated }) => AlterScriptDto.getInstance([script], isActivated, true)); return [...addNotNullConstraintsScript, ...removeNotNullConstraint]; }; diff --git a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/renameColumnHelper.js b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/renameColumnHelper.js index c58be4eb..22feffbe 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/renameColumnHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/renameColumnHelper.js @@ -1,6 +1,12 @@ const _ = require('lodash'); const { AlterScriptDto } = require('../../types/AlterScriptDto'); -const { checkFieldPropertiesChanged, getFullTableName, wrapInQuotes } = require('../../../utils/general'); +const { + checkFieldPropertiesChanged, + getFullTableName, + wrapInQuotes, + isParentContainerActivated, + isObjectInDeltaModelActivated, +} = require('../../../utils/general'); const assignTemplates = require('../../../utils/assignTemplates'); const templates = require('../../../ddlProvider/templates'); @@ -25,14 +31,18 @@ const renameColumn = (tableName, oldColumnName, newColumnName) => { const getRenameColumnScriptDtos = collection => { const fullTableName = getFullTableName(collection); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isObjectInDeltaModelActivated(collection); + return _.values(collection.properties) .filter(jsonSchema => checkFieldPropertiesChanged(jsonSchema.compMod, ['name'])) .map(jsonSchema => { const oldColumnName = wrapInQuotes(jsonSchema.compMod.oldField.name); const newColumnName = wrapInQuotes(jsonSchema.compMod.newField.name); - return renameColumn(fullTableName, oldColumnName, newColumnName); + const isActivated = isContainerActivated && isCollectionActivated && jsonSchema.isActivated; + return { script: renameColumn(fullTableName, oldColumnName, newColumnName), isActivated }; }) - .map(script => AlterScriptDto.getInstance([script], true, false)); + .map(({ script, isActivated }) => AlterScriptDto.getInstance([script], isActivated, false)); }; module.exports = { diff --git a/forward_engineering/alterScript/alterScriptHelpers/containerHelpers/commentsHelper.js b/forward_engineering/alterScript/alterScriptHelpers/containerHelpers/commentsHelper.js index 3ca35d54..3a71b2e0 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/containerHelpers/commentsHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/containerHelpers/commentsHelper.js @@ -1,5 +1,5 @@ const { AlterScriptDto } = require('../../types/AlterScriptDto'); -const { wrapComment, wrapInQuotes } = require('../../../utils/general'); +const { wrapComment, wrapInQuotes, isObjectInDeltaModelActivated } = require('../../../utils/general'); const assignTemplates = require('../../../utils/assignTemplates'); const templates = require('../../../ddlProvider/templates'); @@ -30,7 +30,8 @@ const getUpsertCommentsScriptDto = container => { const wrappedComment = wrapComment(description.new); const wrappedSchemaName = wrapInQuotes(container.role.name); const script = updateSchemaComment(wrappedSchemaName, wrappedComment); - return AlterScriptDto.getInstance([script], true, false); + const isContainerActivated = isObjectInDeltaModelActivated(container); + return AlterScriptDto.getInstance([script], isContainerActivated, false); } return undefined; }; @@ -56,7 +57,8 @@ const getDropCommentsScriptDto = container => { if (description.old && !description.new) { const wrappedSchemaName = wrapInQuotes(container.role.name); const script = dropSchemaComment(wrappedSchemaName); - return AlterScriptDto.getInstance([script], true, true); + const isContainerActivated = isObjectInDeltaModelActivated(container); + return AlterScriptDto.getInstance([script], isContainerActivated, true); } return undefined; }; diff --git a/forward_engineering/alterScript/alterScriptHelpers/containerHelpers/sequencesHelper.js b/forward_engineering/alterScript/alterScriptHelpers/containerHelpers/sequencesHelper.js index 4a043372..1c8c7747 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/containerHelpers/sequencesHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/containerHelpers/sequencesHelper.js @@ -1,7 +1,7 @@ const _ = require('lodash'); const { AlterScriptDto } = require('../../types/AlterScriptDto'); const { App } = require('../../../types/coreApplicationTypes'); -const { getDbName, getGroupItemsByCompMode } = require('../../../utils/general'); +const { getDbName, getGroupItemsByCompMode, isObjectInDeltaModelActivated } = require('../../../utils/general'); const { createSequenceScript, dropSequenceScript, @@ -17,10 +17,11 @@ const sequencesCompModKey = 'sequences'; * */ const getAddContainerSequencesScriptDtos = ({ container }) => { const schemaName = getDbName([container.role]); + const isContainerActivated = isObjectInDeltaModelActivated(container); return (container.role?.sequences || []) .map(sequence => createSequenceScript({ schemaName, sequence })) - .map(script => AlterScriptDto.getInstance([script], true, false)) + .map(script => AlterScriptDto.getInstance([script], isContainerActivated, false)) .filter(Boolean); }; @@ -31,6 +32,7 @@ const getAddContainerSequencesScriptDtos = ({ container }) => { * */ const getModifyContainerSequencesScriptDtos = ({ container }) => { const schemaName = getDbName([container.role]); + const isContainerActivated = isObjectInDeltaModelActivated(container); const sequencesCompMod = container.role?.compMod?.[sequencesCompModKey] || {}; const { new: newItems = [], old: oldItems = [] } = sequencesCompMod; @@ -41,10 +43,10 @@ const getModifyContainerSequencesScriptDtos = ({ container }) => { const removedScriptDtos = removed .map(sequence => dropSequenceScript({ schemaName, sequence })) - .map(script => AlterScriptDto.getInstance([script], true, true)); + .map(script => AlterScriptDto.getInstance([script], isContainerActivated, true)); const addedScriptDtos = added .map(sequence => createSequenceScript({ schemaName, sequence })) - .map(script => AlterScriptDto.getInstance([script], true, false)); + .map(script => AlterScriptDto.getInstance([script], isContainerActivated, false)); const modifiedScriptDtos = modified .map(sequence => { @@ -55,7 +57,7 @@ const getModifyContainerSequencesScriptDtos = ({ container }) => { oldSequence, }); }) - .map(script => AlterScriptDto.getInstance([script], true, false)); + .map(script => AlterScriptDto.getInstance([script], isContainerActivated, false)); return [...modifiedScriptDtos, ...removedScriptDtos, ...addedScriptDtos].filter(Boolean); }; @@ -67,10 +69,11 @@ const getModifyContainerSequencesScriptDtos = ({ container }) => { * */ const getDeleteContainerSequencesScriptDtos = ({ container }) => { const schemaName = getDbName([container.role]); + const isContainerActivated = isObjectInDeltaModelActivated(container); return (container.role?.sequences || []) .map(sequence => dropSequenceScript({ schemaName, sequence })) - .map(script => AlterScriptDto.getInstance([script], true, true)) + .map(script => AlterScriptDto.getInstance([script], isContainerActivated, true)) .filter(Boolean); }; diff --git a/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/checkConstraintHelper.js b/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/checkConstraintHelper.js index ef568ebe..134f73b7 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/checkConstraintHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/checkConstraintHelper.js @@ -1,7 +1,12 @@ const _ = require('lodash'); const { AlterCollectionDto } = require('../../types/AlterCollectionDto'); const { AlterScriptDto } = require('../../types/AlterScriptDto'); -const { getFullTableName, wrapInQuotes } = require('../../../utils/general'); +const { + getFullTableName, + wrapInQuotes, + isParentContainerActivated, + isObjectInDeltaModelActivated, +} = require('../../../utils/general'); const assignTemplates = require('../../../utils/assignTemplates'); const templates = require('../../../ddlProvider/templates'); @@ -142,11 +147,17 @@ const getModifyCheckConstraintScriptDtos = collection => { const fullTableName = getFullTableName(collection); const constraintHistory = mapCheckConstraintNamesToChangeHistory(collection); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isObjectInDeltaModelActivated(collection); + const addCheckConstraintScripts = getAddCheckConstraintScriptDtos(constraintHistory, fullTableName); const dropCheckConstraintScripts = getDropCheckConstraintScriptDtos(constraintHistory, fullTableName); const updateCheckConstraintScripts = getUpdateCheckConstraintScriptDtos(constraintHistory, fullTableName); - return [...addCheckConstraintScripts, ...dropCheckConstraintScripts, ...updateCheckConstraintScripts]; + return [...addCheckConstraintScripts, ...dropCheckConstraintScripts, ...updateCheckConstraintScripts].map(dto => ({ + ...dto, + isActivated: isContainerActivated && isCollectionActivated, + })); }; module.exports = { diff --git a/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/commentsHelper.js b/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/commentsHelper.js index a982875a..ebef834a 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/commentsHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/commentsHelper.js @@ -1,7 +1,12 @@ const _ = require('lodash'); const { AlterScriptDto } = require('../../types/AlterScriptDto'); const { AlterCollectionDto } = require('../../types/AlterCollectionDto'); -const { getFullTableName, wrapComment } = require('../../../utils/general'); +const { + getFullTableName, + wrapComment, + isObjectInDeltaModelActivated, + isParentContainerActivated, +} = require('../../../utils/general'); const assignTemplates = require('../../../utils/assignTemplates'); const templates = require('../../../ddlProvider/templates'); @@ -36,8 +41,11 @@ const getUpdatedCommentOnCollectionScriptDto = collection => { const tableName = getFullTableName(collection); const comment = wrapComment(newComment); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isContainerActivated && isObjectInDeltaModelActivated(collection); + const script = updateTableComment(tableName, comment); - return AlterScriptDto.getInstance([script], true, false); + return AlterScriptDto.getInstance([script], isCollectionActivated, false); }; /** @@ -69,8 +77,11 @@ const getDeletedCommentOnCollectionScriptDto = collection => { const tableName = getFullTableName(collection); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isContainerActivated && isObjectInDeltaModelActivated(collection); + const script = dropTableComment(tableName); - return AlterScriptDto.getInstance([script], true, true); + return AlterScriptDto.getInstance([script], isCollectionActivated, true); }; /** diff --git a/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/primaryKeyHelper.js b/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/primaryKeyHelper.js index b81787d2..757b484b 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/primaryKeyHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/primaryKeyHelper.js @@ -13,6 +13,8 @@ const { getSchemaOfAlterCollection, getEntityName, wrapInQuotes, + isParentContainerActivated, + isObjectInDeltaModelActivated, } = require('../../../utils/general'); const { alterKeyConstraint, dropKeyConstraint } = require('../../../ddlProvider/ddlHelpers/constraintsHelper'); const { areConstraintOptionsEqual } = require('./areConstraintOptionsEqual'); @@ -251,10 +253,13 @@ const getAddCompositePkScriptDtos = collection => { const fullTableName = getFullCollectionName(collectionSchema); const entityName = getEntityName(collectionSchema); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isContainerActivated && isObjectInDeltaModelActivated(collection); + return newPrimaryKeys .map(newPk => { const ddlConfig = getCreateCompositePKDDLProviderConfig(newPk, entityName, collection); - const statementDto = alterKeyConstraint(fullTableName, collection.isActivated, ddlConfig); + const statementDto = alterKeyConstraint(fullTableName, isCollectionActivated, ddlConfig); return new KeyScriptModificationDto(statementDto.statement, fullTableName, false, statementDto.isActivated); }) .filter(scriptDto => Boolean(scriptDto.script)); @@ -286,6 +291,9 @@ const getDropCompositePkScriptDtos = collection => { const fullTableName = getFullCollectionName(collectionSchema); const entityName = getEntityName(collectionSchema); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isContainerActivated && isObjectInDeltaModelActivated(collection); + return oldPrimaryKeys .map(oldPk => { let constraintName = getDefaultConstraintName(entityName); @@ -294,7 +302,7 @@ const getDropCompositePkScriptDtos = collection => { } const ddlConstraintName = wrapInQuotes(constraintName); const script = dropKeyConstraint(fullTableName, ddlConstraintName); - return new KeyScriptModificationDto(script, fullTableName, true, collection.isActivated); + return new KeyScriptModificationDto(script, fullTableName, true, isCollectionActivated); }) .filter(scriptDto => Boolean(scriptDto.script)); }; @@ -563,6 +571,9 @@ const getAddPkScriptDtos = collection => { const fullTableName = getFullCollectionName(collectionSchema); const entityName = getEntityName(collectionSchema); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isContainerActivated && isObjectInDeltaModelActivated(collection); + return _.toPairs(collection.properties) .filter(([name, jsonSchema]) => { if (wasFieldChangedToBeARegularPk(jsonSchema, collection)) { @@ -579,7 +590,7 @@ const getAddPkScriptDtos = collection => { }) .map(([name, jsonSchema]) => { const ddlConfig = getCreateRegularPKDDLProviderConfig(name, jsonSchema, entityName, collection); - const statementDto = alterKeyConstraint(fullTableName, collection.isActivated, ddlConfig); + const statementDto = alterKeyConstraint(fullTableName, isCollectionActivated, ddlConfig); return new KeyScriptModificationDto(statementDto.statement, fullTableName, false, statementDto.isActivated); }) .filter(scriptDto => Boolean(scriptDto.script)); @@ -594,6 +605,9 @@ const getDropPkScriptDto = collection => { const fullTableName = getFullCollectionName(collectionSchema); const entityName = getEntityName(collectionSchema); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isContainerActivated && isObjectInDeltaModelActivated(collection); + return _.toPairs(collection.properties) .filter(([name, jsonSchema]) => { if (isFieldNoLongerARegularPk(jsonSchema, collection)) { @@ -614,7 +628,7 @@ const getDropPkScriptDto = collection => { const ddlConstraintName = wrapInQuotes(getConstraintNameForRegularPk(oldJsonSchema, entityName)); const script = dropKeyConstraint(fullTableName, ddlConstraintName); - return new KeyScriptModificationDto(script, fullTableName, true, collection.isActivated); + return new KeyScriptModificationDto(script, fullTableName, true, isCollectionActivated); }) .filter(scriptDto => Boolean(scriptDto.script)); }; diff --git a/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/uniqueKeyHelper.js b/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/uniqueKeyHelper.js index 6ebb82d2..5bc5e238 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/uniqueKeyHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/uniqueKeyHelper.js @@ -16,6 +16,8 @@ const { getEntityName, getDbVersion, wrapInQuotes, + isParentContainerActivated, + isObjectInDeltaModelActivated, } = require('../../../utils/general'); const { areConstraintOptionsEqual } = require('./areConstraintOptionsEqual'); @@ -264,6 +266,9 @@ const getAddCompositeUniqueKeyScriptDtos = (collection, dbVersion) => { const fullTableName = getFullCollectionName(collectionSchema); const entityName = getEntityName(collectionSchema); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isContainerActivated && isObjectInDeltaModelActivated(collection); + return newUniqueKeys .map(newUniqueKey => { const ddlConfig = getCreateCompositeUniqueKeyDDLProviderConfig( @@ -272,7 +277,7 @@ const getAddCompositeUniqueKeyScriptDtos = (collection, dbVersion) => { collection, dbVersion, ); - const statementDto = alterKeyConstraint(fullTableName, collection.isActivated, ddlConfig); + const statementDto = alterKeyConstraint(fullTableName, isCollectionActivated, ddlConfig); return new KeyScriptModificationDto(statementDto.statement, fullTableName, false, statementDto.isActivated); }) .filter(scriptDto => Boolean(scriptDto.script)); @@ -304,6 +309,9 @@ const getDropCompositeUniqueKeyScriptDtos = collection => { const fullTableName = getFullCollectionName(collectionSchema); const entityName = getEntityName(collectionSchema); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isContainerActivated && isObjectInDeltaModelActivated(collection); + return oldUniqueKeys .map(oldUniqueKey => { let constraintName = getDefaultConstraintName(entityName); @@ -312,7 +320,7 @@ const getDropCompositeUniqueKeyScriptDtos = collection => { } const ddlConstraintName = wrapInQuotes(constraintName); const script = dropKeyConstraint(fullTableName, ddlConstraintName); - return new KeyScriptModificationDto(script, fullTableName, true, collection.isActivated); + return new KeyScriptModificationDto(script, fullTableName, true, isCollectionActivated); }) .filter(scriptDto => Boolean(scriptDto.script)); }; @@ -601,6 +609,9 @@ const getAddUniqueKeyScriptDtos = (collection, dbVersion) => { const fullTableName = getFullCollectionName(collectionSchema); const entityName = getEntityName(collectionSchema); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isContainerActivated && isObjectInDeltaModelActivated(collection); + return _.toPairs(collection.properties) .filter(([name, jsonSchema]) => { if (wasFieldChangedToBeARegularUniqueKey(jsonSchema, collection)) { @@ -623,7 +634,7 @@ const getAddUniqueKeyScriptDtos = (collection, dbVersion) => { collection, dbVersion, ); - const statementDto = alterKeyConstraint(fullTableName, collection.isActivated, ddlConfig); + const statementDto = alterKeyConstraint(fullTableName, isCollectionActivated, ddlConfig); return new KeyScriptModificationDto(statementDto.statement, fullTableName, false, statementDto.isActivated); }) .filter(scriptDto => Boolean(scriptDto.script)); @@ -638,6 +649,9 @@ const getDropUniqueKeyScriptDto = collection => { const fullTableName = getFullCollectionName(collectionSchema); const entityName = getEntityName(collectionSchema); + const isContainerActivated = isParentContainerActivated(collection); + const isCollectionActivated = isContainerActivated && isObjectInDeltaModelActivated(collection); + return _.toPairs(collection.properties) .filter(([name, jsonSchema]) => { if (isFieldNoLongerARegularUniqueKey(jsonSchema, collection)) { @@ -658,7 +672,7 @@ const getDropUniqueKeyScriptDto = collection => { const ddlConstraintName = wrapInQuotes(getConstraintNameForRegularUniqueKey(oldJsonSchema, entityName)); const script = dropKeyConstraint(fullTableName, ddlConstraintName); - return new KeyScriptModificationDto(script, fullTableName, true, collection.isActivated); + return new KeyScriptModificationDto(script, fullTableName, true, isCollectionActivated); }) .filter(scriptDto => Boolean(scriptDto.script)); }; diff --git a/forward_engineering/alterScript/alterScriptHelpers/viewHelpers/commentsHelper.js b/forward_engineering/alterScript/alterScriptHelpers/viewHelpers/commentsHelper.js index 2a01f093..645ac3dd 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/viewHelpers/commentsHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/viewHelpers/commentsHelper.js @@ -1,5 +1,10 @@ const { AlterScriptDto } = require('../../types/AlterScriptDto'); -const { getFullViewName, wrapComment } = require('../../../utils/general'); +const { + getFullViewName, + wrapComment, + isObjectInDeltaModelActivated, + isParentContainerActivated, +} = require('../../../utils/general'); const assignTemplates = require('../../../utils/assignTemplates'); const templates = require('../../../ddlProvider/templates'); @@ -41,8 +46,12 @@ const getUpsertCommentsScriptDto = view => { if (description.new && description.new !== description.old) { const wrappedComment = wrapComment(description.new); const viewName = getFullViewName(view); + + const isContainerActivated = isParentContainerActivated(view); + const isViewActivated = isContainerActivated && isObjectInDeltaModelActivated(view); + const script = updateViewComment(viewName, wrappedComment); - return AlterScriptDto.getInstance([script], true, false); + return AlterScriptDto.getInstance([script], isViewActivated, false); } return undefined; }; @@ -56,8 +65,12 @@ const getDropCommentsScriptDto = view => { if (description.old && !description.new) { const viewName = getFullViewName(view); + + const isContainerActivated = isParentContainerActivated(view); + const isViewActivated = isContainerActivated && isObjectInDeltaModelActivated(view); + const script = dropViewComment(viewName); - return AlterScriptDto.getInstance([script], true, true); + return AlterScriptDto.getInstance([script], isViewActivated, true); } return undefined; }; diff --git a/forward_engineering/ddlProvider/ddlHelpers/constraintsHelper.js b/forward_engineering/ddlProvider/ddlHelpers/constraintsHelper.js index 7f62c37b..edcfcce9 100644 --- a/forward_engineering/ddlProvider/ddlHelpers/constraintsHelper.js +++ b/forward_engineering/ddlProvider/ddlHelpers/constraintsHelper.js @@ -96,7 +96,7 @@ const createKeyConstraint = (templates, isParentActivated) => keyData => { deferrable, deferrableConstraintCheckTime, }), - isActivated: !isAllColumnsDeactivated, + isActivated: !isAllColumnsDeactivated && isParentActivated, }; }; diff --git a/forward_engineering/utils/general.js b/forward_engineering/utils/general.js index ae714718..d3ad15de 100644 --- a/forward_engineering/utils/general.js +++ b/forward_engineering/utils/general.js @@ -269,6 +269,16 @@ const getGroupItemsByCompMode = ({ newItems = [], oldItems = [] }) => { }; }; +const isObjectInDeltaModelActivated = modelObject => { + return modelObject.compMod?.isActivated?.new ?? modelObject.role?.isActivated; +}; + +const isParentContainerActivated = collection => { + return ( + collection?.compMod?.bucketProperties?.isActivated ?? collection?.role?.compMod?.bucketProperties?.isActivated + ); +}; + module.exports = { getDbName, getDbData, @@ -301,4 +311,6 @@ module.exports = { getGroupItemsByCompMode, wrapInSingleQuotes, addCommaPrefix, + isObjectInDeltaModelActivated, + isParentContainerActivated, }; From 21014064ba5ff2bbc85c382830b4b0e124566880 Mon Sep 17 00:00:00 2001 From: Vitalii Bedletskyi Date: Wed, 8 Oct 2025 22:47:44 +0300 Subject: [PATCH 8/8] delete debugger --- forward_engineering/alterScript/alterScriptFromDeltaHelper.js | 1 - 1 file changed, 1 deletion(-) diff --git a/forward_engineering/alterScript/alterScriptFromDeltaHelper.js b/forward_engineering/alterScript/alterScriptFromDeltaHelper.js index b2dd7306..0b1f3483 100644 --- a/forward_engineering/alterScript/alterScriptFromDeltaHelper.js +++ b/forward_engineering/alterScript/alterScriptFromDeltaHelper.js @@ -198,7 +198,6 @@ const getAlterModelDefinitionsScriptDtos = ({ internalDefinitions, externalDefinitions, }) => { - debugger; const createUdtScriptDtos = [] .concat(collection.properties?.modelDefinitions?.properties?.added?.items) .filter(Boolean)