diff --git a/forward_engineering/helpers/general.js b/forward_engineering/helpers/general.js index 4abf5be..c56913d 100644 --- a/forward_engineering/helpers/general.js +++ b/forward_engineering/helpers/general.js @@ -7,18 +7,13 @@ module.exports = app => { const { decorateDefault } = require('./columnDefinitionHelper')(app); const { checkAllKeysDeactivated } = app.require('@hackolade/ddl-fe-utils').general; - const withBrackets = (name, brackets) => (brackets ? `[${name}]` : name); - const getTableName = (tableName, schemaName, brackets = true) => { - const name = withBrackets(tableName, brackets); - - return schemaName ? `${withBrackets(schemaName, brackets)}.${name}` : name; - }; - - const getIndexName = ({ name, schemaName, brackets = true }) => { - const indexName = withBrackets(name, brackets); - - return schemaName ? `${withBrackets(schemaName, brackets)}.${indexName}` : indexName; + const withBrackets = name => (brackets ? `[${name}]` : name); + if (schemaName) { + return `${withBrackets(schemaName)}.${withBrackets(tableName)}`; + } else { + return withBrackets(tableName); + } }; const getDefaultValue = (defaultValue, defaultConstraintName, type) => { @@ -267,7 +262,6 @@ module.exports = app => { filterColumnStoreProperties, getKeyWithAlias, getTableName, - getIndexName, getTableOptions, hasType, getViewData, diff --git a/forward_engineering/helpers/indexHelper.js b/forward_engineering/helpers/indexHelper.js index 8913414..382ad1e 100644 --- a/forward_engineering/helpers/indexHelper.js +++ b/forward_engineering/helpers/indexHelper.js @@ -4,7 +4,7 @@ const BOUNDING_BOX_LABEL = ['XMIN', 'YMIN', 'XMAX', 'YMAX']; module.exports = app => { const _ = app.require('lodash'); - const { filterColumnStoreProperties, getTableName, getIndexName } = require('./general')(app); + const { filterColumnStoreProperties, getTableName } = require('./general')(app); const { assignTemplates } = app.require('@hackolade/ddl-fe-utils'); const { divideIntoActivatedAndDeactivated, checkAllKeysDeactivated } = app.require('@hackolade/ddl-fe-utils').general; @@ -82,7 +82,7 @@ module.exports = app => { : ''; return assignTemplates(templates.index, { - name: getIndexName({ name: index.name, schemaName: index.schemaName }), + name: index.name, unique: index.unique ? ' UNIQUE' : '', clustered: index.clustered ? ' CLUSTERED' : '', table: getTableName(tableName, index.schemaName), @@ -159,7 +159,7 @@ module.exports = app => { return isParentActivated ? commentIfDeactivated(column, key) : column; }) .join(',\n\t'), - indexName: getIndexName({ name: index.keyIndex, schemaName: index.schemaName }), + indexName: index.keyIndex, catalog: catalog ? `ON ${catalog}\n` : '', options: options ? `WITH (\n\t${options}\n)` : '', terminator, @@ -212,7 +212,7 @@ module.exports = app => { const options = getSpatialOptions(index); return assignTemplates(templates.spatialIndex, { - name: getIndexName({ name: index.name, schemaName: index.schemaName }), + name: index.name, table: getTableName(tableName, index.schemaName), column: `[${index.column.name}]`, using: index.using ? `\nUSING ${index.using}` : '',