import type { DatabaseObjectType, DatabaseType } from "@/types/database"; import * as api from "@/lib/api"; export type RenameableObjectType = DatabaseObjectType; export interface BuildRenameObjectSqlOptions { databaseType?: DatabaseType; objectType: RenameableObjectType; schema?: string | null; oldName: string; newName: string; } const postgresLikeRenameTypes = new Set([ "postgres", "redshift", "gaussdb", "kingbase", "highgo", "vastbase", ]); const oracleLikeRenameTypes = new Set(["oracle", "dameng"]); export function supportsObjectRename( databaseType: DatabaseType | undefined, objectType: RenameableObjectType, ): boolean { if (!databaseType) return false; if (databaseType === "sqlserver") return true; if (objectType === "PROCEDURE" || objectType === "FUNCTION") { return false; } if (databaseType === "sqlite") return objectType === "TABLE"; if (databaseType === "mysql" || databaseType === "goldendb") return objectType === "TABLE" || objectType === "VIEW"; if (postgresLikeRenameTypes.has(databaseType)) return objectType === "TABLE" || objectType === "VIEW"; if (oracleLikeRenameTypes.has(databaseType)) return objectType === "TABLE" || objectType === "VIEW"; return false; } export function buildRenameObjectSql(options: BuildRenameObjectSqlOptions): Promise { return api.buildRenameObjectSql(options); }