diff --git a/forward_engineering/alterScript/alterScriptFromDeltaHelper.js b/forward_engineering/alterScript/alterScriptFromDeltaHelper.js index 214e023..a23331c 100644 --- a/forward_engineering/alterScript/alterScriptFromDeltaHelper.js +++ b/forward_engineering/alterScript/alterScriptFromDeltaHelper.js @@ -132,6 +132,7 @@ const sortCollectionsByRelationships = (collections, relationships) => { * internalDefinitions: InternalDefinitions, * externalDefinitions: ExternalDefinitions, * shouldIgnoreColumnComments?: boolean, + * shouldIgnoreTableComments?: boolean, * }} * @return {AlterScriptDto[]} * */ @@ -144,6 +145,7 @@ const getAlterCollectionsScriptDtos = ({ externalDefinitions, inlineDeltaRelationships, shouldIgnoreColumnComments = false, + shouldIgnoreTableComments = false, }) => { const entitiesData = collection.properties?.entities?.properties; const createScriptsData = getItemProperties(entitiesData?.added); @@ -168,7 +170,9 @@ const getAlterCollectionsScriptDtos = ({ .filter(collection => collection.compMod?.deleted) .map(getDeleteCollectionScriptDto(app)); - const modifyCollectionScriptDtos = modifyScriptsData.flatMap(getModifyCollectionScriptDtos({ dbVersion })); + const modifyCollectionScriptDtos = modifyScriptsData.flatMap( + getModifyCollectionScriptDtos({ dbVersion, shouldIgnoreTableComments }), + ); const modifyCollectionKeysScriptDtos = modifyScriptsData.flatMap(getModifyCollectionKeysScriptDtos({ dbVersion })); const addColumnScriptDtos = createScriptsData @@ -400,6 +404,8 @@ const getAlterScriptDtos = (data, app) => { const inlineDeltaRelationships = getInlineRelationships({ collection, options: data.options }); const shouldIgnoreColumnComments = data.options?.scriptGenerationOptions?.feActiveOptions?.columnComments === 'ignore'; + const shouldIgnoreTableComments = + data.options?.scriptGenerationOptions?.feActiveOptions?.tableComments === 'ignore'; const containersScriptDtos = getAlterContainersScriptDtos({ collection }); const collectionsScriptDtos = getAlterCollectionsScriptDtos({ collection, @@ -410,6 +416,7 @@ const getAlterScriptDtos = (data, app) => { externalDefinitions, inlineDeltaRelationships, shouldIgnoreColumnComments, + shouldIgnoreTableComments, }); const viewScriptDtos = getAlterViewScriptDtos(collection, app); const modelDefinitionsScriptDtos = getAlterModelDefinitionsScriptDtos({ diff --git a/forward_engineering/alterScript/alterScriptHelpers/alterEntityHelper.js b/forward_engineering/alterScript/alterScriptHelpers/alterEntityHelper.js index 2b8502f..2687853 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/alterEntityHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/alterEntityHelper.js @@ -120,10 +120,13 @@ const getDeleteCollectionScriptDto = app => collection => { * @return {(collection: AlterCollectionDto) => AlterScriptDto[]} * */ const getModifyCollectionScriptDtos = - ({ dbVersion }) => + ({ dbVersion, shouldIgnoreTableComments = false }) => collection => { const modifyCheckConstraintScriptDtos = getModifyCheckConstraintScriptDtos(collection); - const modifyCommentScriptDtos = getModifyEntityCommentsScriptDtos(collection); + const modifyCommentScriptDtos = getModifyEntityCommentsScriptDtos({ + collection, + shouldIgnoreTableComments, + }); return [...modifyCheckConstraintScriptDtos, ...modifyCommentScriptDtos].filter(Boolean); }; diff --git a/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/commentsHelper.js b/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/commentsHelper.js index 5cae07c..5a34ec9 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/commentsHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/entityHelpers/commentsHelper.js @@ -25,16 +25,26 @@ const updateTableComment = (tableName, comment) => { }; /** - * @param {AlterCollectionDto} collection + * @param {{ collection: AlterCollectionDto, shouldIgnoreTableComments?: boolean }} dto * @return {AlterScriptDto} */ -const getUpdatedCommentOnCollectionScriptDto = collection => { - const descriptionInfo = collection?.role.compMod?.description; - if (!descriptionInfo) { +const getUpdatedCommentOnCollectionScriptDto = ({ collection, shouldIgnoreTableComments = false } = {}) => { + if (shouldIgnoreTableComments) { return undefined; } - const { old: oldComment, new: newComment } = descriptionInfo; + const outerDescription = collection?.role.compMod?.description; + if (!outerDescription) { + return undefined; + } + + const firstCompareDescription = collection?.role.role?.compMod?.description; + if (collection?.role.role && firstCompareDescription == null) { + return undefined; + } + + const oldComment = firstCompareDescription?.old ?? outerDescription.old; + const newComment = outerDescription.new ?? firstCompareDescription?.new; if (!newComment || newComment === oldComment) { return undefined; } @@ -62,10 +72,14 @@ const dropTableComment = tableName => { }; /** - * @param {AlterCollectionDto} collection + * @param {{ collection: AlterCollectionDto, shouldIgnoreTableComments?: boolean }} dto * @return {AlterScriptDto} */ -const getDeletedCommentOnCollectionScriptDto = collection => { +const getDeletedCommentOnCollectionScriptDto = ({ collection, shouldIgnoreTableComments = false } = {}) => { + if (shouldIgnoreTableComments) { + return undefined; + } + const descriptionInfo = collection?.role.compMod?.description; if (!descriptionInfo) { return undefined; @@ -86,12 +100,18 @@ const getDeletedCommentOnCollectionScriptDto = collection => { }; /** - * @param {AlterCollectionDto} collection + * @param {{ collection: AlterCollectionDto, shouldIgnoreTableComments?: boolean }} dto * @return {Array} - * */ -const getModifyEntityCommentsScriptDtos = collection => { - const updatedCommentScript = getUpdatedCommentOnCollectionScriptDto(collection); - const deletedCommentScript = getDeletedCommentOnCollectionScriptDto(collection); + */ +const getModifyEntityCommentsScriptDtos = ({ collection, shouldIgnoreTableComments = false } = {}) => { + const updatedCommentScript = getUpdatedCommentOnCollectionScriptDto({ + collection, + shouldIgnoreTableComments, + }); + const deletedCommentScript = getDeletedCommentOnCollectionScriptDto({ + collection, + shouldIgnoreTableComments, + }); return [updatedCommentScript, deletedCommentScript].filter(Boolean); };