Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "HCK-8971: include schema name in index name of DDL (#122)" #123

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading