@@ -5,10 +5,14 @@ import {
55} from "@electric-sql/pglite-socket" ;
66import { drizzle , type PgliteDatabase } from "drizzle-orm/pglite" ;
77import type { FumaDB } from "fumadb" ;
8+ import {
9+ createDrizzleRuntimeSchemaFromTables ,
10+ ensureDrizzleRuntimeSchemaFromTables ,
11+ } from "fumadb/adapters/drizzle" ;
12+
13+ import type { FumaDb , FumaTables } from "@executor-js/sdk" ;
814
9- import type { FumaDb , FumaTables } from "./fuma-runtime" ;
10- import { createDrizzleFumaDb } from "./drizzle" ;
11- import { createPostgresDrizzleSchema , ensurePostgresFumaSchema } from "./drizzle-schema" ;
15+ import { createDrizzleFumaDb } from "./fuma" ;
1216
1317export interface PgliteFumaDb {
1418 readonly db : FumaDb ;
@@ -22,7 +26,7 @@ export interface PgliteFumaDb {
2226
2327export interface CreatePgliteFumaDbOptions < TTables extends FumaTables = FumaTables > {
2428 readonly tables : TTables ;
25- readonly namespace ? : string ;
29+ readonly namespace : string ;
2630 readonly version ?: string ;
2731 readonly dataDir ?: string ;
2832 readonly host ?: string ;
@@ -33,26 +37,29 @@ export const createPgliteFumaDb = async <const TTables extends FumaTables>(
3337 options : CreatePgliteFumaDbOptions < TTables > ,
3438) : Promise < PgliteFumaDb > => {
3539 const version = options . version ?? "1.0.0" ;
36- const namespace = options . namespace ?? "executor" ;
3740 const pglite = await PGlite . create ( options . dataDir ?? "memory://" ) ;
38- const drizzleSchema = createPostgresDrizzleSchema ( {
41+ const schema = createDrizzleRuntimeSchemaFromTables ( {
3942 tables : options . tables ,
40- namespace,
43+ namespace : options . namespace ,
4144 version,
45+ provider : "postgresql" ,
4246 } ) ;
4347 const drizzleDb = drizzle ( {
4448 client : pglite ,
45- schema : drizzleSchema ,
49+ schema,
4650 } ) ;
47- await ensurePostgresFumaSchema ( drizzleDb , {
51+
52+ await ensureDrizzleRuntimeSchemaFromTables ( drizzleDb , {
4853 tables : options . tables ,
49- namespace,
54+ namespace : options . namespace ,
5055 version,
56+ provider : "postgresql" ,
5157 } ) ;
58+
5259 const fuma = createDrizzleFumaDb ( {
5360 db : drizzleDb ,
5461 tables : options . tables ,
55- namespace,
62+ namespace : options . namespace ,
5663 version,
5764 provider : "postgresql" ,
5865 } ) ;
0 commit comments