Skip to content

Commit

Permalink
HCK-9173: comment out inactive schema statement in script (#52)
Browse files Browse the repository at this point in the history
* HCK-9173: comment out inactive schema statement in script

* fix: comment out if isActivated is not FALSE

* remove unused lib

* fix undefined
  • Loading branch information
AlikRakhmonov authored Dec 19, 2024
1 parent 9ff3a58 commit d64d2e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 4 additions & 1 deletion forward_engineering/ddlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ module.exports = (baseProvider, options, app) => {
functions,
procedures,
comment,
isActivated = true,
}) {
let database;
const schemaComment = assignTemplates(templates.comment, {
Expand Down Expand Up @@ -86,9 +87,10 @@ module.exports = (baseProvider, options, app) => {
const userProcedures = procedures.map(procedure =>
assignTemplates(templates.createProcedure, setOrReplace(procedure)),
);
return [database, comment ? _.trimStart(schemaComment) : '', ...userFunctions, ...userProcedures]
const statement = [database, comment ? _.trimStart(schemaComment) : '', ...userFunctions, ...userProcedures]
.filter(Boolean)
.join('\n');
return commentIfDeactivated(statement, { isActivated });
},

createTable(tableData, isActivated) {
Expand Down Expand Up @@ -283,6 +285,7 @@ module.exports = (baseProvider, options, app) => {
? procedures.map(hydrateProcedure(containerData.name)).filter(filterProcedure)
: [],
comment: containerData.description,
isActivated: containerData.isActivated,
};
},

Expand Down
4 changes: 1 addition & 3 deletions forward_engineering/helpers/commentDeactivatedHelper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const _ = require('lodash');

const commentIfDeactivated = (statement, data, isPartOfLine) => {
if (_.has(data, 'isActivated') && !data.isActivated) {
if (data.isActivated === false) {
if (isPartOfLine) {
return '/* ' + statement + ' */';
} else if (statement.includes('\n')) {
Expand Down

0 comments on commit d64d2e2

Please sign in to comment.