fix(postgres): keep index operator classes in read and generation

Closes #7166
This commit is contained in:
Tara authored and GitHub committed 2026-09-04 14:48:41 +08:00
1 parent 09f8d095d2
commit 01623ab38d
31 files changed
+854 -51

No files matched your search

@@ -41,6 +41,11 @@ const structureCapabilities = computed(() => getTableStructureCapabilities(props
const validationErrors = ref<string[]>([]);
const sqlText = ref("");
const warnings = ref<string[]>([]);
// 仅 GIN 缺 opclass 警告阻断同步;其余降级类警告(如 “… not supported … ignored”)保持可继续。
// Match the warning's stable semantic core ("has no operator class specified")
// rather than its prefix, so rewording the leading "GIN index …" doesn't
// silently disable the gate.
const hasBlockingWarning = computed(() => warnings.value.some((w) => w.includes("has no operator class specified")));
const building = ref(false);
const executing = ref(false);
const execError = ref("");
@@ -122,7 +127,7 @@ async function copySql() {
}
async function execute() {
if (!sqlText.value || validationErrors.value.length) return;
if (!sqlText.value || validationErrors.value.length || hasBlockingWarning.value) return;
executing.value = true;
execError.value = "";
try {
@@ -190,7 +195,7 @@ function syncTableLabel(table: DiagramTable): string {
<DialogFooter class="gap-2 sm:gap-2">
<Button type="button" variant="outline" size="sm" :disabled="!sqlText" @click="copySql">{{ t("diagram.copySql") }}</Button>
<Button type="button" variant="ghost" size="sm" @click="openModel = false">{{ t("common.cancel") }}</Button>
<Button type="button" size="sm" :disabled="!sqlText || !!validationErrors.length || executing || building" @click="execute">
<Button type="button" size="sm" :disabled="!sqlText || !!validationErrors.length || hasBlockingWarning || executing || building" @click="execute">
{{ executing ? t("diagram.syncing") : t("diagram.executeSync") }}
</Button>
</DialogFooter>
@@ -3173,6 +3173,7 @@ function addIndex() {
includedColumns: [],
comment: "",
concurrently: false,
columnOpclasses: [],
markedForDrop: false,
});
void nextTick(() => {
@@ -40,6 +40,7 @@ export function createDraftIndex(tableName: string, columns: string[], existingI
includedColumns: [],
comment: "",
concurrently: false,
columnOpclasses: [],
markedForDrop: false,
};
}
@@ -46,6 +46,8 @@ export interface EditableStructureIndex {
comment: string;
/** Build the index with PostgreSQL `CREATE INDEX CONCURRENTLY` (PostgreSQL only, default off). */
concurrently?: boolean;
/** Parallel to `columns`: operator class for each key column (PostgreSQL). `null` means default. */
columnOpclasses?: (string | null)[];
original?: IndexInfo;
markedForDrop: boolean;
}
@@ -1029,6 +1029,7 @@ export function createIndexDrafts(indexes: IndexInfo[]): EditableStructureIndex[
indexType: normalizeStructureIndexType(index.index_type),
includedColumns: index.included_columns ? [...index.included_columns] : [],
comment: index.comment ?? "",
columnOpclasses: index.column_opclasses ? [...index.column_opclasses] : [],
original: index,
markedForDrop: false,
}));
+2
View File
@@ -552,6 +552,8 @@ export interface IndexInfo {
comment?: string | null;
/** Parallel to `columns`: true at index i means columns[i] is a raw expression, not a plain column name. */
key_is_expression?: boolean[] | null;
/** Parallel to `columns`: operator class name for each key column (PostgreSQL), if non-default. */
column_opclasses?: (string | null)[] | null;
}
export interface ReferenceKeyInfo {