How can I properly configure Drizzle?
I'm following the Prisma migration guide and I have a few problems: My database is in my own schema, but I can't find the option to specify the schema. Drizzle defaults to
public
which is an antipattern (and also empty in my case).
Apart from this even though I configure Drizzle to put the schema
file in a specific folder:
it puts the resulting schema.ts
in ./src/drizzle/schema.ts
Is this something I can configure?8 Replies
I've opened a bug ticket as I've exhausted all options and this seems to be a bug in Drizzle itself: https://github.com/drizzle-team/drizzle-orm/issues/2449
GitHub
[BUG]: Drizzle doesn't use the schema part of a database connection...
What version of drizzle-orm are you using? 0.31.0 What version of drizzle-kit are you using? 0.22.1 Describe the Bug I have the following DATABASE_URL in my .env file: DATABASE_URL=postgresql://x:x...
I'm not very familiar with Postgres, but IIRC you just append a
search_path=mySchema
parameter to the connection string.
From a little searching, it also sounds like your user might be configured to use or prioritize public
by default. It looks like you can change that from the shell via
(such that the search_path
parameter in the connection string should not be necessary)
https://www.postgresql.org/docs/16/ddl-schemas.html#DDL-SCHEMAS-PATHI have that in my connection string and it doesn't work
partly because the migrations are wrong
all enums are generated into the
public
schema and there is no way to change that
Oh okay yeah - that's a problem 😬
😅
there are other problems too
https://discord.com/channels/1043890932593987624/1247567682539098234
the main problem is that i'm migrating from prisma and all of this was working before. I'm using the official docker image for postgresql and this worked with every tool I've used before (prisma / kysely / typeorm) so I think it should work with Drizzle out of the box....but even then it should be an option to explicitly specify a
schema
and it should be consistent with how the migrator worksOh I totally agree. It definitely seems like a bug or oversight in the migrator implementation, and I would think fairly high priority for impairing users trying to transition to the Drizzle suite. If the Kit source was presently available, I'm curious enough about all of this that I'd love to try and track down the responsible code - not that this is really in my general wheelhouse
What is the Prisma Migration guide that you're following, out of curiosity?
for me this is a blocker right now 😅
Drizzle ORM - Migrate from Prisma to Drizzle
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.