Seems like the schema generic is missing - did you forget to add it to your DB type?

Hi, I am trying to use Drizzle in a multischema setup. The docs say to make the config and then create the db adapter. I would assume that the folder I set as schema in drizzle.config.ts would automatically pass it to the db client. But I get
Seems like the schema generic is missing - did you forget to add it to your DB type?
Seems like the schema generic is missing - did you forget to add it to your DB type?
. Do I have to explicitly define all the schemas I'm using in the db client like: export const database = drizzle(sqlite, {schema1, schema2}) , or is there something wrong? The way it seems in the setup for the docs, all I need is to define the schema folder and the db() should gather the types from it automatically.
import { defineConfig } from "drizzle-kit";

export default defineConfig({
schema: "./src/db/schema",
out: "./src/db/migrations",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL || "",
},
});
import { defineConfig } from "drizzle-kit";

export default defineConfig({
schema: "./src/db/schema",
out: "./src/db/migrations",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL || "",
},
});
5 Replies
salzar
salzarOP2w ago
Pls
spdermn
spdermn2w ago
you need to pass the schema in you drizzle() init for each schema I suppose, not sure how it would work otherwise
salzar
salzarOP2w ago
I figured when you defined it in the config that was good enough for the types to populate, because the get started docs never mention to add the schema to the drizzle() init So I’m not really 100% sure on how to do it with multiple schemas, but I could prolly just make a barrel file or something
Sillvva
Sillvva2w ago
I think the config file is primarily for migrations. You still need to pass it to the drizzle() init for runtime code.
salzar
salzarOP2w ago
Gotcha thanks that seems right, it’s weird they don’t have you do that in the docs

Did you find this page helpful?