Skip to content

Commit

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

This reverts commit e518474.
  • Loading branch information
Nightlngale authored Dec 5, 2024
1 parent e518474 commit 1468c91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
18 changes: 6 additions & 12 deletions forward_engineering/helpers/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -267,7 +262,6 @@ module.exports = app => {
filterColumnStoreProperties,
getKeyWithAlias,
getTableName,
getIndexName,
getTableOptions,
hasType,
getViewData,
Expand Down
8 changes: 4 additions & 4 deletions forward_engineering/helpers/indexHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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}` : '',
Expand Down

0 comments on commit 1468c91

Please sign in to comment.