Skip to content

Commit

Permalink
HCK-8971: include schema name in index name of DDL (#99)
Browse files Browse the repository at this point in the history
* HCK-8971: include schema name in index name of DDL

* HCK-8971: fix comments
  • Loading branch information
Nightlngale authored Dec 4, 2024
1 parent 1c8bcce commit 4bebaf0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions forward_engineering/helpers/indexHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ module.exports = app => {
: activatedKeys + (deactivatedKeys ? ', ' : '') + deactivatedKeys;
};

const getIndexName = ({ name, schemaName }) => {
const indexName = name ? `[${name}]` : '';

if (!indexName) {
return '';
}

return schemaName ? `[${schemaName}].[${indexName}]` : indexName;
};

const createIndex = (terminator, tableName, index, isParentActivated = true) => {
if (_.isEmpty(index.keys) || !index.name) {
return '';
Expand All @@ -97,7 +107,7 @@ module.exports = app => {
const clustered = index.clustered ? ` CLUSTERED` : ' NONCLUSTERED';

return assignTemplates(templates.index, {
name: index.name,
name: getIndexName({ name: index.name, schemaName: index.schemaName }),
clustered,
table: getTableName(tableName, index.schemaName),
keys,
Expand All @@ -115,7 +125,7 @@ module.exports = app => {
const order = getIndexKeys(index.orderKeys || [], key => `[${key.name}]`, isParentActivated);

return assignTemplates(templates.columnStoreIndex, {
name: index.name,
name: getIndexName({ name: index.name, schemaName: index.schemaName }),
table: getTableName(tableName, index.schemaName),
order: order ? `\n\tORDER (${order})` : '',
index_options: createIndexOptions(indexOptions),
Expand Down

0 comments on commit 4bebaf0

Please sign in to comment.