feat(safety): temporary write-unlock window for read-only connections

This commit is contained in:
Farahani authored and GitHub committed 2026-08-27 17:37:54 +08:00
1 parent 7933b7656f
commit 955558c81f
66 files changed
+1176 -124

No files matched your search

@@ -1,5 +1,6 @@
import type { ConnectionConfig, DatabaseType, TreeNodeType } from "@/types/database";
import { supportsCreateDatabaseCharset } from "@/lib/database/createDatabaseSql";
import { connectionIsEffectivelyReadOnly } from "@/lib/database/readOnlyWriteAccess";
export type DatabasePropertyEditGroup = "charsetCollation" | "databaseComment" | "schemaComment";
@@ -9,7 +10,7 @@ export interface DatabasePropertyEditingEntry {
deferred?: string;
}
type PropertyEditConnection = Pick<ConnectionConfig, "db_type" | "driver_profile" | "read_only"> | undefined;
type PropertyEditConnection = (Pick<ConnectionConfig, "db_type" | "driver_profile" | "read_only"> & Partial<Pick<ConnectionConfig, "id">>) | undefined;
type DatabaseNode = Pick<{ type: TreeNodeType; database?: string | null }, "type" | "database">;
type SchemaNode = Pick<{ type: TreeNodeType; database?: string | null; schema?: string | null }, "type" | "database" | "schema">;
@@ -97,7 +98,7 @@ export const DATABASE_PROPERTY_EDITING_MATRIX = {
} satisfies Record<DatabaseType, DatabasePropertyEditingEntry>;
function entryFor(connection: PropertyEditConnection): DatabasePropertyEditingEntry | null {
if (!connection || connection.read_only) return null;
if (!connection || connectionIsEffectivelyReadOnly(connection)) return null;
return DATABASE_PROPERTY_EDITING_MATRIX[connection.db_type] ?? null;
}