feat(sqlite): support attached database schema changes
This commit is contained in:
41 files changed
+1219
-129
No files matched your search
@@ -11,13 +11,13 @@ export interface DatabaseNamespaceCreationMatrixEntry {
|
||||
deferred?: string;
|
||||
}
|
||||
|
||||
type CreationConnection = Pick<ConnectionConfig, "db_type" | "driver_profile" | "read_only"> | undefined;
|
||||
type CreationConnection = (Pick<ConnectionConfig, "db_type" | "driver_profile" | "read_only"> & Partial<Pick<ConnectionConfig, "host" | "password">>) | undefined;
|
||||
|
||||
// Keep creation target-specific: many products expose schemas, files, or provider-managed namespaces instead of a top-level database.
|
||||
export const DATABASE_NAMESPACE_CREATION_MATRIX = {
|
||||
mysql: { connection: "database" },
|
||||
postgres: { connection: "database", database: "schema" },
|
||||
sqlite: { deferred: "file-backed; create a new connection/file instead" },
|
||||
sqlite: { connection: "attach" },
|
||||
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" },
|
||||
@@ -85,6 +85,9 @@ export const DATABASE_NAMESPACE_CREATION_MATRIX = {
|
||||
export function connectionNamespaceCreationTarget(connection: CreationConnection): ConnectionCreationTarget | null {
|
||||
if (!connection || connection.read_only) return null;
|
||||
if (connection.db_type === "mongodb" && connection.driver_profile === "mongodb-legacy") return null;
|
||||
if (connection.db_type === "sqlite" && (connection.host?.trim().toLowerCase() === ":memory:" || Boolean(connection.password))) {
|
||||
return null;
|
||||
}
|
||||
const entry: DatabaseNamespaceCreationMatrixEntry = DATABASE_NAMESPACE_CREATION_MATRIX[connection.db_type];
|
||||
return entry.connection ?? null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user