Skip to content

Commit 84708a9

Browse files
HCK-9173: comment out inactive schema statement in script (#125)
* HCK-9173: comment out inactive schema statement in script * fix: comment out if isActivated is not FALSE * fix undefined
1 parent 536c12e commit 84708a9

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

forward_engineering/ddlProvider.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = (baseProvider, options, app) => {
4545
const terminator = getTerminator(options);
4646

4747
return {
48-
createSchema({ schemaName, databaseName, ifNotExist, comment }) {
48+
createSchema({ schemaName, databaseName, ifNotExist, comment, isActivated = true }) {
4949
const schemaTerminator = ifNotExist ? ';' : terminator;
5050

5151
const schemaComment = comment
@@ -56,11 +56,14 @@ module.exports = (baseProvider, options, app) => {
5656
})
5757
: '';
5858

59-
let schemaStatement = assignTemplates(templates.createSchema, {
60-
name: schemaName,
61-
terminator: schemaTerminator,
62-
comment: schemaComment ? `\n\n${schemaComment}` : '',
63-
});
59+
let schemaStatement = commentIfDeactivated(
60+
assignTemplates(templates.createSchema, {
61+
name: schemaName,
62+
terminator: schemaTerminator,
63+
comment: schemaComment ? `\n\n${schemaComment}` : '',
64+
}),
65+
{ isActivated },
66+
);
6467

6568
if (!databaseName) {
6669
return ifNotExist
@@ -500,6 +503,7 @@ module.exports = (baseProvider, options, app) => {
500503
databaseName: containerData.databaseName,
501504
ifNotExist: containerData.ifNotExist,
502505
comment: containerData.role?.description ?? containerData.description,
506+
isActivated: containerData.isActivated,
503507
};
504508
},
505509

forward_engineering/helpers/commentIfDeactivated.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const BEFORE_DEACTIVATED_STATEMENT = '-- ';
22
const REG_FOR_MULTYLINE_COMMENT = /(\n\/\*\n[\s\S]*?\n\s\*\/\n)|((\n\/\*\n[\s\S]*?\n\s\*\/)$)/gi;
33

44
const commentIfDeactivated = (statement, data, isPartOfLine) => {
5-
if (data?.hasOwnProperty('isActivated') && !data.isActivated) {
5+
if (data.isActivated === false) {
66
if (isPartOfLine) {
77
return '/* ' + statement + ' */';
88
} else if (statement.includes('\n')) {

0 commit comments

Comments
 (0)