DB type error

I have looked at other help questions for this, but they don't really help me understanding the issues I have.

I can do something like:

import * as schema from "@root/models/user.model";
...
export const db = drizzle(pool, { schema });

I don't really see this on the site or in the docs, or any explanation of why I need to do this. Instead, the docs show that you can throw them into db/schemas/ as whatever files you want and that's it. I do have a drizzle.config.ts file which points towards my schemas and a migrate.ts that works fine.

If I don't do the above I get errors like:

Property 'users' does not exist on type 'DrizzleTypeError<"Seems like the schema generic is missing - did you forget to add it to your DB type?">'.


So, my questions are:

  1. Do I need use the above method of "registering" schemas?
  2. Is there a way to add multiple schema files?
Was this page helpful?