feat(d1): add Cloudflare D1 database support
This commit is contained in:
1 parent
977e7f78ca
commit
2a92746dc0
61 files changed
+1732
-69
No files matched your search
@@ -75,4 +75,4 @@ export const DATABASE_OBJECT_TREE_TYPES = new Set<DatabaseType>(["jdbc"]);
|
||||
|
||||
export const PG_LIKE_STRUCTURE_TYPES = new Set<DatabaseType>(["postgres", "redshift", "gaussdb", "kwdb", "opengauss", "questdb"]);
|
||||
|
||||
export const DIAGRAM_SQL_TYPES = new Set<DatabaseType>(["mysql", "postgres", "sqlite", "rqlite", "turso", "sqlserver", "oracle", "redshift", "dameng", "gaussdb", "kwdb", "opengauss", "questdb", "oceanbase-oracle"]);
|
||||
export const DIAGRAM_SQL_TYPES = new Set<DatabaseType>(["mysql", "postgres", "sqlite", "rqlite", "turso", "cloudflare-d1", "sqlserver", "oracle", "redshift", "dameng", "gaussdb", "kwdb", "opengauss", "questdb", "oceanbase-oracle"]);
|
||||
@@ -118,7 +118,7 @@ export function supportsObjectBrowserTreeNode(dbType: DatabaseType | undefined,
|
||||
}
|
||||
|
||||
export function supportsTableTruncate(dbType?: DatabaseType): boolean {
|
||||
return !!dbType && dbType !== "sqlite" && dbType !== "rqlite" && dbType !== "turso" && dbType !== "duckdb" && dbType !== "influxdb" && dbType !== "manticoresearch";
|
||||
return !!dbType && dbType !== "sqlite" && dbType !== "rqlite" && dbType !== "turso" && dbType !== "cloudflare-d1" && dbType !== "duckdb" && dbType !== "influxdb" && dbType !== "manticoresearch";
|
||||
}
|
||||
|
||||
export function usesPostgresLikeStructureCopy(dbType?: DatabaseType): boolean {
|
||||
|
||||
@@ -20,6 +20,7 @@ export const DATABASE_NAMESPACE_CREATION_MATRIX = {
|
||||
sqlite: { deferred: "file-backed; create a new connection/file instead" },
|
||||
rqlite: { deferred: "single SQLite-compatible database per node" },
|
||||
turso: { deferred: "remote libSQL database lifecycle is provider-managed" },
|
||||
"cloudflare-d1": { deferred: "Cloudflare D1 database lifecycle is provider-managed" },
|
||||
redis: { deferred: "numbered logical databases are server-configured" },
|
||||
duckdb: { connection: "attach" },
|
||||
clickhouse: { connection: "database" },
|
||||
|
||||
@@ -35,6 +35,7 @@ const DATABASE_TYPE_OBJECTS = new Map<DatabaseType, SidebarObjectKind[]>([
|
||||
["sqlite", TABLE_VIEW_OBJECTS],
|
||||
["rqlite", TABLE_VIEW_OBJECTS],
|
||||
["turso", TABLE_VIEW_OBJECTS],
|
||||
["cloudflare-d1", TABLE_VIEW_OBJECTS],
|
||||
["duckdb", TABLE_VIEW_OBJECTS],
|
||||
["clickhouse", TABLE_VIEW_OBJECTS],
|
||||
["doris", TABLE_VIEW_OBJECTS],
|
||||
|
||||
@@ -21,6 +21,7 @@ export const DATABASE_PROPERTY_EDITING_MATRIX = {
|
||||
sqlite: { deferred: "file-backed database properties are not edited in-place" },
|
||||
rqlite: { deferred: "single SQLite-compatible database per node" },
|
||||
turso: { deferred: "remote libSQL database lifecycle is provider-managed" },
|
||||
"cloudflare-d1": { deferred: "Cloudflare D1 database lifecycle is provider-managed" },
|
||||
redis: { deferred: "numbered logical databases are server-configured" },
|
||||
duckdb: { deferred: "attached database file properties need a dedicated DuckDB workflow" },
|
||||
clickhouse: { deferred: "database property editing not verified for first pass" },
|
||||
|
||||
@@ -52,6 +52,7 @@ const NAVICAT_STYLE_TABLE_DATA_TYPES = new Set<DatabaseType>([
|
||||
"sqlite",
|
||||
"rqlite",
|
||||
"turso",
|
||||
"cloudflare-d1",
|
||||
"duckdb",
|
||||
"sqlserver",
|
||||
"oracle",
|
||||
|
||||
@@ -4,7 +4,8 @@ import { usesTreeSchemaMode } from "@/lib/database/databaseCapabilities";
|
||||
export const TREE_SCHEMA_DEFAULT_DATABASE_SELECT_VALUE = "__dbx_tree_schema_default_database__";
|
||||
export const EMPTY_DATABASE_SELECT_VALUE = "__dbx_empty_database__";
|
||||
|
||||
export function resolveDefaultDatabase(connection: Pick<ConnectionConfig, "database">, options: string[]): string {
|
||||
export function resolveDefaultDatabase(connection: Pick<ConnectionConfig, "database"> & Partial<Pick<ConnectionConfig, "db_type">>, options: string[]): string {
|
||||
if (connection.db_type === "cloudflare-d1") return "main";
|
||||
return connection.database || options[0] || "";
|
||||
}
|
||||
|
||||
@@ -29,6 +30,7 @@ export function formatDatabaseLabel(connection: Pick<ConnectionConfig, "db_type"
|
||||
return database || labels.noDatabase;
|
||||
}
|
||||
|
||||
export function isDefaultDatabase(connection: Pick<ConnectionConfig, "database"> | undefined, database: string): boolean {
|
||||
export function isDefaultDatabase(connection: (Pick<ConnectionConfig, "database"> & Partial<Pick<ConnectionConfig, "db_type">>) | undefined, database: string): boolean {
|
||||
if (connection?.db_type === "cloudflare-d1") return database === "main";
|
||||
return !!connection?.database && !!database && connection.database === database;
|
||||
}
|
||||
Reference in new issue
Block a user