diff --git a/forward_engineering/ddlProvider/ddlHelpers/indexHelper.js b/forward_engineering/ddlProvider/ddlHelpers/indexHelper.js index 2eb6ad5..773b2f9 100644 --- a/forward_engineering/ddlProvider/ddlHelpers/indexHelper.js +++ b/forward_engineering/ddlProvider/ddlHelpers/indexHelper.js @@ -1,9 +1,13 @@ const _ = require('lodash'); -module.exports = ({ _, prepareName }) => { +module.exports = ({ _, prepareName, getNamePrefixedWithSchemaName }) => { const getIndexType = indexType => { return indexType ? ` ${_.toUpper(indexType)}` : ''; }; + const getIndexName = ({ index }) => { + return index.indxName ? ` ${getNamePrefixedWithSchemaName(index.indxName, index.schemaName)}` : ''; + }; + /** * @param indxKey {Array | undefined} * @param column_expression {string | undefined} @@ -57,12 +61,10 @@ module.exports = ({ _, prepareName }) => { return options; }; - const getIndexName = name => (name ? ` ${prepareName(name)}` : ''); - return { + getIndexName, getIndexType, getIndexKeys, getIndexOptions, - getIndexName, }; }; diff --git a/forward_engineering/ddlProvider/ddlProvider.js b/forward_engineering/ddlProvider/ddlProvider.js index 3e99967..be1005e 100644 --- a/forward_engineering/ddlProvider/ddlProvider.js +++ b/forward_engineering/ddlProvider/ddlProvider.js @@ -91,9 +91,10 @@ module.exports = (baseProvider, options, app) => { prepareName, }); - const { getIndexType, getIndexKeys, getIndexOptions, getIndexName } = require('./ddlHelpers/indexHelper')({ + const { getIndexType, getIndexName, getIndexKeys, getIndexOptions } = require('./ddlHelpers/indexHelper')({ _, prepareName, + getNamePrefixedWithSchemaName, }); const wrapIfNotExists = (statement, ifNotExist, errorCode = 955) => { @@ -490,7 +491,6 @@ module.exports = (baseProvider, options, app) => { }, createIndex(tableName, index, dbData, isParentActivated = true) { - const name = getIndexName(index.indxName); const indexType = getIndexType(index.indxType); const keys = getIndexKeys(index); const indexOptions = getIndexOptions(index); @@ -502,7 +502,7 @@ module.exports = (baseProvider, options, app) => { let statement = assignTemplates(templates.createIndex, { indexType, ifNotExists: shouldInsertIfNotExistsStatement ? ' IF NOT EXISTS' : '', - name, + name: getIndexName({ index }), keys, options: indexOptions, tableName: getNamePrefixedWithSchemaName(tableName, index.schemaName), @@ -591,7 +591,6 @@ module.exports = (baseProvider, options, app) => { }, createViewIndex(viewName, index, dbData, isParentActivated) { - const name = getIndexName(index.indxName); const indexType = getIndexType(index.indxType); const keys = getIndexKeys(index); const options = getIndexOptions(index, isParentActivated); @@ -603,7 +602,7 @@ module.exports = (baseProvider, options, app) => { return commentIfDeactivated( assignTemplates(templates.createIndex, { indexType, - name, + name: getIndexName({ index }), keys, options, tableName: getNamePrefixedWithSchemaName(viewName, index.schemaName),