fix(structure): show PostgreSQL index types in editor

This commit is contained in:
onenewcode authored and GitHub committed 2026-07-30 16:49:14 +08:00
1 parent 50e49d06bc
commit 1650b0605a
3 files changed
+58 -2

No files matched your search

@@ -758,6 +758,16 @@ export function rehydrateColumnDraftsFromMetadata(draftColumns: EditableStructur
return [...nextColumns, ...missingMetadataDrafts];
}
/** Canonicalize index method for structure editor options (e.g. Postgres `btree` → `BTREE`). */
export function normalizeStructureIndexType(indexType: string | null | undefined): string {
return (indexType ?? "").trim().toUpperCase();
}
/** Case-insensitive index-type equality (draft is uppercased; API may still return lowercase amname). */
export function sameStructureIndexType(left: string | null | undefined, right: string | null | undefined): boolean {
return normalizeStructureIndexType(left) === normalizeStructureIndexType(right);
}
export function createIndexDrafts(indexes: IndexInfo[]): EditableStructureIndex[] {
return indexes.map((index) => ({
id: `existing:${index.name}`,
@@ -767,7 +777,8 @@ export function createIndexDrafts(indexes: IndexInfo[]): EditableStructureIndex[
isUnique: index.is_unique,
isPrimary: index.is_primary,
filter: index.filter ?? "",
indexType: index.index_type ?? "",
// Match Select options (BTREE/GIN/…); Postgres pg_am.amname is lowercase.
indexType: normalizeStructureIndexType(index.index_type),
includedColumns: index.included_columns ? [...index.included_columns] : [],
comment: index.comment ?? "",
original: index,