Skip to content

Commit

Permalink
HCK-8971: Restore "Create index" recent changes (#149)
Browse files Browse the repository at this point in the history
* Revert "HCK-8971: include schema name in index name of DDL (#147)"

This reverts commit aa029c0.

* Reapply "HCK-8971: include schema name in index name of DDL (#147)"

This reverts commit c609fd6.

* Reapply "HCK-8971

* small fix
  • Loading branch information
Nightlngale authored Dec 6, 2024
1 parent a27cdd4 commit 1d2b5fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions forward_engineering/ddlProvider/ddlHelpers/indexHelper.js
Original file line number Diff line number Diff line change
@@ -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<Object> | undefined}
* @param column_expression {string | undefined}
Expand Down Expand Up @@ -57,12 +61,10 @@ module.exports = ({ _, prepareName }) => {
return options;
};

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

return {
getIndexName,
getIndexType,
getIndexKeys,
getIndexOptions,
getIndexName,
};
};
5 changes: 3 additions & 2 deletions forward_engineering/ddlProvider/ddlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ module.exports = (baseProvider, options, app) => {
const { getIndexType, getIndexKeys, getIndexOptions, getIndexName } = require('./ddlHelpers/indexHelper')({
_,
prepareName,
getNamePrefixedWithSchemaName,
});

const wrapIfNotExists = (statement, ifNotExist, errorCode = 955) => {
Expand Down Expand Up @@ -490,7 +491,7 @@ module.exports = (baseProvider, options, app) => {
},

createIndex(tableName, index, dbData, isParentActivated = true) {
const name = getIndexName(index.indxName);
const name = getIndexName({ index });
const indexType = getIndexType(index.indxType);
const keys = getIndexKeys(index);
const indexOptions = getIndexOptions(index);
Expand Down Expand Up @@ -591,7 +592,7 @@ module.exports = (baseProvider, options, app) => {
},

createViewIndex(viewName, index, dbData, isParentActivated) {
const name = getIndexName(index.indxName);
const name = getIndexName({ index });
const indexType = getIndexType(index.indxType);
const keys = getIndexKeys(index);
const options = getIndexOptions(index, isParentActivated);
Expand Down

0 comments on commit 1d2b5fa

Please sign in to comment.