Skip to content

Commit

Permalink
Revert "HCK-8971: include schema name in index name of DDL (#35)" (#36)
Browse files Browse the repository at this point in the history
This reverts commit 5096a56.
  • Loading branch information
Nightlngale authored Dec 5, 2024
1 parent 5096a56 commit 0e072b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 34 deletions.
7 changes: 2 additions & 5 deletions forward_engineering/ddlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = (baseProvider, options, app) => {
const { assignTemplates, compareGroupItems } = app.require('@hackolade/ddl-fe-utils');
const { decorateDefault, decorateType, canBeNational, getSign, createGeneratedColumn, canHaveAutoIncrement } =
require('./helpers/columnDefinitionHelper')(_, wrap);
const { getTableName, getIndexName, getTableOptions, getPartitions, getViewData, getCharacteristics, escapeQuotes } =
const { getTableName, getTableOptions, getPartitions, getViewData, getCharacteristics, escapeQuotes } =
require('./helpers/general')(_, wrap);
const { generateConstraintsString, foreignKeysToString, foreignActiveKeysToString, createKeyConstraint } =
require('./helpers/constraintsHelper')({
Expand Down Expand Up @@ -430,10 +430,7 @@ module.exports = (baseProvider, options, app) => {
const wholeStatementCommented = index.isActivated === false || !isParentActivated || allDeactivated;
const indexType =
index.indexType && _.toUpper(index.indexType) !== 'KEY' ? `${_.toUpper(index.indexType)} ` : '';
const name = getIndexName({
name: index.indxName,
schemaName: dbData.databaseName,
})
const name = wrap(index.indxName || '', '`', '`');
const table = getTableName(tableName, dbData.databaseName);
const indexCategory = index.indexCategory ? ` USING ${index.indexCategory}` : '';
let indexOptions = [];
Expand Down
33 changes: 4 additions & 29 deletions forward_engineering/helpers/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,14 @@ module.exports = (_, wrap) => {
NDB: ['KEY_BLOCK_SIZE'],
};

/**
* @param {Object} params
* @param {string} params.name
* @param {string} params.schemaName
* @returns {string}
* */
const getNamePrefixedWithSchemaName = ({ name, schemaName }) => {
const getTableName = (tableName, schemaName) => {
if (schemaName) {
return `\`${schemaName}\`.\`${name}\``;
return `\`${schemaName}\`.\`${tableName}\``;
} else {
return `\`${tableName}\``;
}
return `\`${name}\``;
};

/**
* @param schemaName {string}
* @param tableName {string}
* @return {string}
* */
const getTableName = (tableName, schemaName) => {
return getNamePrefixedWithSchemaName({ name: tableName, schemaName });
};

/**
* @param {Object} params
* @param {string} params.name
* @param {string} params.schemaName
* @returns {string}
*/
const getIndexName = ({ name, schemaName }) => {
return getNamePrefixedWithSchemaName({ name, schemaName });
}

const getOptionValue = (keyword, value) => {
if (['ROW_FORMAT', 'INSERT_METHOD'].includes(keyword)) {
if (value) {
Expand Down Expand Up @@ -347,7 +323,6 @@ module.exports = (_, wrap) => {

return {
getTableName,
getIndexName,
getTableOptions,
getPartitions,
getViewData,
Expand Down

0 comments on commit 0e072b6

Please sign in to comment.