refactor: centralize database type groups into databaseCapabilities.ts

Extract all inline database type checks (schema-aware, pagination style,
feature support sets, etc.) into a single source of truth. Adding a new
database type now requires updating only one file instead of 15+.
This commit is contained in:
t8y2
2026-05-07 02:36:50 +08:00
parent fde76d5576
commit 629bd02b0f
11 changed files with 153 additions and 155 deletions
+2 -7
View File
@@ -9,6 +9,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@
import { useConnectionStore } from "@/stores/connectionStore";
import DatabaseIcon from "@/components/icons/DatabaseIcon.vue";
import * as api from "@/lib/api";
import { isSchemaAware } from "@/lib/databaseCapabilities";
import { diffColumns, diffIndexes, diffTables, generateSyncSql, type TableDiff } from "@/lib/schemaDiff";
import { useToast } from "@/composables/useToast";
import { Loader2, Copy, Play, GitCompareArrows } from "lucide-vue-next";
@@ -72,13 +73,7 @@ async function loadDatabases(connectionId: string, side: "source" | "target") {
async function resolveSchema(connectionId: string, database: string): Promise<string> {
const config = store.getConfig(connectionId);
const needsSchema =
config?.db_type === "postgres" ||
config?.db_type === "sqlserver" ||
config?.db_type === "oracle" ||
config?.db_type === "redshift" ||
config?.db_type === "dameng" ||
config?.db_type === "gaussdb";
const needsSchema = isSchemaAware(config?.db_type);
if (needsSchema) {
const schemas = await api.listSchemas(connectionId, database);
return schemas.includes("public") ? "public" : (schemas[0] ?? "");