Skip to content

Commit

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

* fix undefined
  • Loading branch information
AlikRakhmonov authored Dec 19, 2024
1 parent 531ec73 commit 9a638d1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions forward_engineering/ddlProvider/ddlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ module.exports = (baseProvider, options, app) => {
udfs,
procedures,
useDb = true,
isActivated = true,
}) {
let dbOptions = '';
dbOptions += characterSet ? tab(`\nCHARACTER SET = '${characterSet}'`) : '';
Expand All @@ -108,7 +109,9 @@ module.exports = (baseProvider, options, app) => {
const udfStatements = udfs.map(udf => this.createUdf(databaseName, udf));
const procStatements = procedures.map(procedure => this.createProcedure(databaseName, procedure));

return [databaseStatement, ...udfStatements, ...procStatements].join('\n');
return commentIfDeactivated([databaseStatement, ...udfStatements, ...procStatements].join('\n'), {
isActivated,
});
},

/**
Expand Down Expand Up @@ -157,7 +160,7 @@ module.exports = (baseProvider, options, app) => {
const foreignKeyConstraintsString = generateConstraintsString(dividedForeignKeys, isActivated);
const columnStatements = joinActivatedAndDeactivatedStatements({ statements: columns, indent: '\n\t' });

return assignTemplates(templates.createTable, {
const statement = assignTemplates(templates.createTable, {
name: tableName,
column_definitions: columnStatements,
selectStatement: selectStatement ? ` ${selectStatement}` : '',
Expand All @@ -170,6 +173,8 @@ module.exports = (baseProvider, options, app) => {
foreignKeyConstraints: foreignKeyConstraintsString,
keyConstraints: keyConstraintsString,
});

return commentIfDeactivated(statement, { isActivated });
},

mapColumnToColumnDefinitionDdl,
Expand Down Expand Up @@ -521,6 +526,7 @@ module.exports = (baseProvider, options, app) => {
comments: containerData.description,
udfs: (data?.udfs || []).map(this.hydrateUdf),
procedures: (data?.procedures || []).map(this.hydrateProcedure),
isActivated: containerData.isActivated,
};
},

Expand Down

0 comments on commit 9a638d1

Please sign in to comment.