Skip to content

Commit

Permalink
HCK-8971: include schema name in index name of DDL (#147)
Browse files Browse the repository at this point in the history
* Revert "HCK-8740: [Oracle] RE from DDL file: missing quotation for default values reversed from 'ALTER COLUMN MODIFY' (#145)"

This reverts commit ea6c5a8.

* HCK-8971: include schema name in index name of DDL

* HCK-8971: fix comments

* HCK-8971: move to separate function
  • Loading branch information
Nightlngale authored Dec 4, 2024
1 parent cb781e9 commit aa029c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 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,
};
};
9 changes: 4 additions & 5 deletions forward_engineering/ddlProvider/ddlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);
Expand All @@ -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),
Expand Down Expand Up @@ -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);
Expand All @@ -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),
Expand Down

0 comments on commit aa029c0

Please sign in to comment.