multiple schema files

Hi im a bit confused on how to use multiple schemas. When i use mutiple files, db._.fullSchema retuns a emty object. this is my drizzle config:
import "dotenv/config";
import { defineConfig } from "drizzle-kit";
export default defineConfig({
out: "./server/drizzle",
schema: "./server/db/schema",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});
import "dotenv/config";
import { defineConfig } from "drizzle-kit";
export default defineConfig({
out: "./server/drizzle",
schema: "./server/db/schema",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});
and this is how i init the db
import "dotenv/config";
import { drizzle } from "drizzle-orm/node-postgres";
export const db = drizzle(process.env.DATABASE_URL!);
import "dotenv/config";
import { drizzle } from "drizzle-orm/node-postgres";
export const db = drizzle(process.env.DATABASE_URL!);
See image for file struct. Can anyone tell me what im doing wrong?
No description
2 Replies
TOSL
TOSL4w ago
There is a difference between passing schema path in the config and the drizzle initialization. You need to pass your schema to the initialization.
const db = drizzle(env.DATABASE_URL, { schema})
const db = drizzle(env.DATABASE_URL, { schema})
schema path is for drizzle-kit so that drizzle can do migrations
TheConsoleGardenMG
This was indeed what i needed tnx

Did you find this page helpful?