Drizzle Team

DT

Drizzle Team

The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!

Join

Drizzle Schema and TS

Hello, I have a question around how are we expected to consume the types from the schema generated by drizzle-kit pull . ```ts // schema.ts export const user_points = pgTable(...

drizzle-zod create schema does not return a usable zod object

createInsertSchema, createSelectSchema, etc does not return a zod object that can be used it is returning a BuildSchema type which is not compatible with other libs using zod...

Proper type for relational query

How can I generically type for the result of a relational query? Am I supposed to be able to use SQLiteRelationalQuery? I'm having trouble getting types to work if so. ```ts interface RelationalQueryFn<?> { (ids: string[]): SQLiteRelationalQuery<?>...

Running into URL constructor issues when combined with Auth0's NextJS package

Hey all; I'm currently running into some really annoying issues when trying to insert a user into my database once they have been authenticated by Auth0. I'm attempting to do this in the beforeSessionSaved handler within the Auth0Client. I've opened a ticket for them to take a look at but I wondered if there's anything I can do on the Drizzle side?...

Shared databases for multiple schemas?

hey folks. just wondering if anyone is running a shared database for 2 or more apps and managing migrations for this pattern? either with a singular schema-and-migration-only project, or separate schema+migrations (1 per app) against the shared db? I ask because the latter would be cleaner but the in-db migration management schema seems to not like this....

drizzle kit CI Github action

Hey guys, I am trying to automate migrations: I got this Github Action: ```migrate: if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest...

drizzle-zod sqlite enums not being able to createInsertSchemas

i can't generate insertSchamas here's my code: ` export const products = sqliteTable('products', {...
No description

Workaround for a working ddtrace?

It's a known problem that ddtrace (or any other otel?) is not playing nice with drizzle by default. Is there a way to workaround this problem and define a trace external to drizzle?

Using values from an input

Hello! I'm trying to solve an issue I have with an endpoint I'm working on. I have to be able to provide values to override in the query, something like the mock-up code bellow. Is something like this possible? ```ts const overridenValues = new Map<Id, Date>([[1, "2025-01-01"]])...

How can I query data without having to map the values with JavaScript?

I only want to get the movie and actors, but I get repeated data: ```ts async function getMovieWithActors(title: string) { return db .select({...

Fixes for composite PK?

https://github.com/drizzle-team/drizzle-orm/issues/3383 Referencing this issue, using composite primary keys like the author here with errno: 1553 on subsequent pushes, took a look at the migration code that was generated and it seems like its not dropping the foreign key constraints and drop and recreating the primary key. Tried using pnpm patch to patch drizzle with the suggested fix here: https://github.com/drizzle-team/drizzle-orm/issues/1428#issuecomment-1916722940 but it did not fix the issue as I am using named primary keys. Cannot seem for the life of me get this to work. Do I have to manually create migrations and fix such issues or what is the proposed solution? Seems like using composite primary keys is one of the most used SQL features and donno why more people haven't ran into this issue. Would love to see if anybody has fixses for the issue?...

pgTable - extra config (primaryKey) issues

I seem to be having some issues with pgTable - which I can't figure out. Could someone lend me a hand as I have been trying all day 🙂 I tried asking in the #orm-beta but not had a response. I'm super stuck and this is blocking my deployment of RQB-V2. (my code in thread) I seem to be having some issues with pgTable, any time I build with the current beta I get errors related to the extra config. I know I was previously using the now deprecated object notation, and I switched that to the array, but still get the issues. I also tried both with and without the function option, which caused issues too. ...

Switch mysql database with same connection

Is it possible to switch/query a different database under the same mysql connection? I can't find any docs on it, yet this comment from a maintainer indicates you can: https://github.com/drizzle-team/drizzle-orm/discussions/2461#discussioncomment-9692910

What's is the recommended way to do DB migrations, when deploying to vercel?

Now I do the migration right after building the app, here is my build command: vinxi build && drizzle-kit push Is this approach fine, or is there some gotchas? What's the recommended way to solve it? Couldn't find info in docs...

Custom query at the end of migrations

So for some context, i use Durable objects which require me to run the migrate function alot. most of the time this will be skipped because the db has not changed so its not an issue. But i was wondering what would be a good way of running a pragma optimize at the end? i only want to run this IF there has been changes aka if the migrations arent skipped. Simple way is obviously manually adding that query in the last migration file but i was wondering if there is another way of doing this? the migrate function sadly dosent return a result that says if migrations ran or were skipped...

Migration Error: DrizzleError: Failed to run the query CREATE TABLED

The migrations won't update, I keep getting this error, not sure how to fix it. All I did was add another column. I did delete the drizzle folder and kept generating a new one but alas doesn't work.
No description

How can I select array of users and their related projects (many) as array?

Imagine I have these schemas: ```ts // users table export const users = pgTable("users", { id: uuid("id").primaryKey().defaultRandom(),...

Can't push migrations to Neon from a deno project (DNS error?)

I'm trying to push some migrations to a Neon database. Config for reference: ``` // drizzle.config.ts...

drizzle kit CI Github action

Hey guys, I am trying to automate migrations: I got this Github Action: ``` migrate: if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest...

help in connecting postgres server with .pem file

i have created a postgres server using aiven and i got a database url and a ca certificate but don't know how to connect to the database using drizzle. also there is nothing related to this in the docs. SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain os: win11...