({
tableId,
oldIndex,
newIndex,
diffMap,
changedTables,
changedIndexes,
attributes,
changedTablesAttributes,
changedIndexesAttributes,
databaseType,
}: {
tableId: string;
oldIndex: DBIndex;
newIndex: DBIndex;
diffMap: DiffMap;
changedTables: Map<string, boolean>;
changedIndexes: Map<string, boolean>;
attributes?: IndexDiffAttribute[];
changedTablesAttributes?: TableDiffAttribute[];
changedIndexesAttributes?: IndexDiffAttribute[];
databaseType: DatabaseType;
})
| 1060 | |
| 1061 | // Compare index properties |
| 1062 | function compareIndexProperties({ |
| 1063 | tableId, |
| 1064 | oldIndex, |
| 1065 | newIndex, |
| 1066 | diffMap, |
| 1067 | changedTables, |
| 1068 | changedIndexes, |
| 1069 | attributes, |
| 1070 | changedTablesAttributes, |
| 1071 | changedIndexesAttributes, |
| 1072 | databaseType, |
| 1073 | }: { |
| 1074 | tableId: string; |
| 1075 | oldIndex: DBIndex; |
| 1076 | newIndex: DBIndex; |
| 1077 | diffMap: DiffMap; |
| 1078 | changedTables: Map<string, boolean>; |
| 1079 | changedIndexes: Map<string, boolean>; |
| 1080 | attributes?: IndexDiffAttribute[]; |
| 1081 | changedTablesAttributes?: TableDiffAttribute[]; |
| 1082 | changedIndexesAttributes?: IndexDiffAttribute[]; |
| 1083 | databaseType: DatabaseType; |
| 1084 | }) { |
| 1085 | // If attributes are specified, only check those attributes |
| 1086 | const attributesToCheck: IndexDiffAttribute[] = attributes ?? [ |
| 1087 | 'name', |
| 1088 | 'unique', |
| 1089 | 'fieldIds', |
| 1090 | 'type', |
| 1091 | 'comments', |
| 1092 | ]; |
| 1093 | |
| 1094 | const changedAttributes: IndexDiffAttribute[] = []; |
| 1095 | |
| 1096 | if (attributesToCheck.includes('name') && oldIndex.name !== newIndex.name) { |
| 1097 | changedAttributes.push('name'); |
| 1098 | } |
| 1099 | |
| 1100 | if ( |
| 1101 | attributesToCheck.includes('unique') && |
| 1102 | oldIndex.unique !== newIndex.unique |
| 1103 | ) { |
| 1104 | changedAttributes.push('unique'); |
| 1105 | } |
| 1106 | |
| 1107 | if ( |
| 1108 | attributesToCheck.includes('fieldIds') && |
| 1109 | !areFieldIdsEqual(oldIndex.fieldIds, newIndex.fieldIds) |
| 1110 | ) { |
| 1111 | changedAttributes.push('fieldIds'); |
| 1112 | } |
| 1113 | |
| 1114 | if (attributesToCheck.includes('type')) { |
| 1115 | const oldType = |
| 1116 | oldIndex.type ?? defaultIndexTypeForDatabase[databaseType]; |
| 1117 | const newType = |
| 1118 | newIndex.type ?? defaultIndexTypeForDatabase[databaseType]; |
| 1119 |
no test coverage detected