drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.14k stars 615 forks source link

[BUG]: Cannot create migrations when using: import "server-only" #1844

Open gnllucena opened 9 months ago

gnllucena commented 9 months ago

What version of drizzle-orm are you using?

0.29.3

What version of drizzle-kit are you using?

0.20.13

Describe the Bug

Clone repo https://github.com/gnllucena/drizzle-import-server-only

bun install bun run migration:generate

The command will only create the meta folder and the _journal.json file on src/server/data/migrations/ folder.

If you remove the import “server-only” from src/server/data/schema/customers-schema.ts you’ll notice that the migrations are generated normally.

Expected behavior

The migrations should be created when schema uses import "server-only"

Environment & setup

OS: macOS 14.2.1 23C71 arm64 Kernel: 23.2.0 Shell: fish 3.5.0

413n commented 9 months ago

I'm encountering a similar problem when running drizzle-kit studio where my schema.ts file has import "server-only" that crashes the cli.

gnllucena commented 8 months ago

Issue persists on "drizzle-kit": "^0.20.14"

Repo updated

mayatron commented 4 months ago

As a workaround, I was able to bypass the server-only error when running drizzle-kit commands. I'm not sure if this works with bun though.

NODE_OPTIONS="--conditions=react-server" drizzle-kit ...

Relevant docs: