Skip to content

Commit

Permalink
Revert "HCK-8971: include schema name in index name of DDL (#147)" (#148
Browse files Browse the repository at this point in the history
)

This reverts commit aa029c0.
  • Loading branch information
Nightlngale authored Dec 5, 2024
1 parent aa029c0 commit a27cdd4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 4 additions & 6 deletions forward_engineering/ddlProvider/ddlHelpers/indexHelper.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
const _ = require('lodash');
module.exports = ({ _, prepareName, getNamePrefixedWithSchemaName }) => {
module.exports = ({ _, prepareName }) => {
const getIndexType = indexType => {
return indexType ? ` ${_.toUpper(indexType)}` : '';
};

const getIndexName = ({ index }) => {
return index.indxName ? ` ${getNamePrefixedWithSchemaName(index.indxName, index.schemaName)}` : '';
};

/**
* @param indxKey {Array<Object> | undefined}
* @param column_expression {string | undefined}
Expand Down Expand Up @@ -61,10 +57,12 @@ module.exports = ({ _, prepareName, getNamePrefixedWithSchemaName }) => {
return options;
};

const getIndexName = name => (name ? ` ${prepareName(name)}` : '');

return {
getIndexName,
getIndexType,
getIndexKeys,
getIndexOptions,
getIndexName,
};
};
9 changes: 5 additions & 4 deletions forward_engineering/ddlProvider/ddlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ module.exports = (baseProvider, options, app) => {
prepareName,
});

const { getIndexType, getIndexName, getIndexKeys, getIndexOptions } = require('./ddlHelpers/indexHelper')({
const { getIndexType, getIndexKeys, getIndexOptions, getIndexName } = require('./ddlHelpers/indexHelper')({
_,
prepareName,
getNamePrefixedWithSchemaName,
});

const wrapIfNotExists = (statement, ifNotExist, errorCode = 955) => {
Expand Down Expand Up @@ -491,6 +490,7 @@ 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);
Expand All @@ -502,7 +502,7 @@ module.exports = (baseProvider, options, app) => {
let statement = assignTemplates(templates.createIndex, {
indexType,
ifNotExists: shouldInsertIfNotExistsStatement ? ' IF NOT EXISTS' : '',
name: getIndexName({ index }),
name,
keys,
options: indexOptions,
tableName: getNamePrefixedWithSchemaName(tableName, index.schemaName),
Expand Down Expand Up @@ -591,6 +591,7 @@ 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);
Expand All @@ -602,7 +603,7 @@ module.exports = (baseProvider, options, app) => {
return commentIfDeactivated(
assignTemplates(templates.createIndex, {
indexType,
name: getIndexName({ index }),
name,
keys,
options,
tableName: getNamePrefixedWithSchemaName(viewName, index.schemaName),
Expand Down

0 comments on commit a27cdd4

Please sign in to comment.