Skip to content

Commit 2fe9ea6

Browse files
HCK-13020: comment index statement if statement, table or all columns inactive (#165)
1 parent fc512d4 commit 2fe9ea6

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

forward_engineering/ddlProvider/ddlHelpers/indexHelper.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ const mapIndexKey = ({ name, sortOrder, nullsOrder, collation, opclass }) => {
2020
return `${wrapInQuotes(name)}${collationStr}${opclassStr}${sortOrderStr}${nullsOrderStr}`;
2121
};
2222

23-
const getIndexKeys = ({ columns = [], isParentActivated }) => {
24-
const isAllColumnsDeactivated = checkAllKeysDeactivated(columns);
25-
23+
const getIndexKeys = ({ columns = [], isParentActivated, isAllColumnsDeactivated }) => {
2624
return getColumnsList(columns, isAllColumnsDeactivated, isParentActivated, mapIndexKey);
2725
};
2826

@@ -114,9 +112,12 @@ const createIndex = (tableName, index, dbData, isParentActivated = true) => {
114112
? index.columns
115113
: _.map(index.columns, column => _.omit(column, 'sortOrder', 'nullsOrder'));
116114

115+
const isAllColumnsDeactivated = checkAllKeysDeactivated(indexColumns);
116+
117117
const keys = getIndexKeys({
118118
columns: indexColumns,
119119
isParentActivated,
120+
isAllColumnsDeactivated,
120121
});
121122
const options = getIndexOptions(index, isParentActivated);
122123

@@ -134,7 +135,7 @@ const createIndex = (tableName, index, dbData, isParentActivated = true) => {
134135
tableName: getNamePrefixedWithSchemaName(tableName, index.schemaName),
135136
}),
136137
{
137-
isActivated: index.isActivated,
138+
isActivated: index.isActivated && isParentActivated && !isAllColumnsDeactivated,
138139
},
139140
);
140141
};

0 commit comments

Comments
 (0)