Problem with generating migrations

Hi, i have made a question on stackoverflow: https://stackoverflow.com/questions/78423964/generate-drizzle-migrations-in-nodenext-project Can someone help me with this issue? Thanks!
Stack Overflow
Generate drizzle migrations in NodeNext project
I want to use Drizzle ORM in my api. The api is a workspace in a monorepo build with Turborepo. I want to generate migrations with drizzle-kit, with the following command drizzle-kit generate:pg. I...
4 Replies
stumpykilo
stumpykilo7mo ago
Does your config look like Example 3 from this page? https://orm.drizzle.team/kit-docs/conf#schema-files-paths If so you may want to consider adding an index.ts in your schema folder that exports all of your schemas. After that you should be able import like this: import { users, } from "@/drizzle/schema";
Drizzle ORM - Configuration
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Senna
SennaOP7mo ago
First, thanks for your answer! Yes I am using a structure like example 3. But this won't fix the problem. Everything works fine if I put all my model definitions in one schema. But this is makes my models less readable in a big application. So i want to split them up like on the screenshot. In my drizzle.config.ts I set the schema option to all files in the data folder: schema: './src/data/*'. But there when i try to generate a migration, the drizzle-kit cli finds the user.js import and can't map it to the ts file.
No description
stumpykilo
stumpykilo7mo ago
I have multiple schema files as well and my imports from other schema files look like this: import { user } from "./user"; Are you exporting all of your schema files with an index.ts like this? export * from "./user";
Senna
SennaOP7mo ago
Yes but that doen't make sense. As you can see, my imports are with the .js extension. Because in my tsconfig I set the properties module and moduleResolution to NodeNext. Since I want to build my project to JavaScript with tsc.
Want results from more Discord servers?
Add your server