Drizzle Team

DT

Drizzle Team

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

Join

cant insert after using drizzle-seed

schema ```ts const usersTable = pgTable('users', { id: integer().primaryKey().generatedAlwaysAsIdentity(), email: varchar({ length: 255 }).notNull().unique(),...

No schema loaded in Drizzle Studio

I'm starting up Drizzle Studio after updating to the latest versions: "drizzle-kit": "0.29.0", "drizzle-orm": "0.37.0". The studio loads in with no schema and I have no idea why. I'm connecting to a Planetscale DB and following the docs to a tee using their driver. My configurations are all correct, and I can confirm my environment variables are making it into the config and everywhere else. I do have this set up in a monorepo, but this only recently started occurring. I even reverted to an older version and the same things happens. - Introspection seems to work just fine...
No description

What's the recommended way to handle joins that aggregate results?

I'm currently converting a codebase that uses raw sql postgres queries over to drizzle, and have this query: ```sql SELECT games.name, games.image_url,...

with clause type not being inferred properly on insert

I have to assert it as a number for the type error to go away: ``` const countryIdQuery = db.$with('country_id').as( db...

How to dynamically select all columns from one table, and join a single column from another table?

Its pretty often that I need to grab some details from a relational table and add it in to my original query. However, when I do this, I then need to explicitly call out all columns on the original table, and compose in my values from the join table. This can become tedious when I have many columns or when a column is added on the original table. I was hoping I might be able to spread out my reference to the PgTable and just add in one other key for the other table, but this isn't a valid query. Wrong ```typescript const existingReport = await db...

Does local.drizzle.studio/index.js weight 18 megabytes for real?

Hello! I am not sure if my internet speed is so slow or your build is broken, but did https://local.drizzle.studio/index.js always weight 18 megabytes? It takes ages to load drizzle studio in web browser. When it loads, it works....

Next.js, Drizzle and Supabase DB with transactions?

Hey, I really appreciate the value of transactions. They grant safety when handling multiple changes at once. I am setting up my Next.js project. I want to use Drizzle to handle my tables in my code....

Unable to modify data in drizzle studio

Error : Please add a primary key column to your table to update or delete rows. this is my package.json ```json "drizzle-orm": "^0.35.3",...
No description

All other relations drop when creating a new one

```js export const homologationSchemas = createTable( "homologation_schemas", { id: serialUuid(),...

Custom postgres JSON_AGG function help

I want to create a function simmilar to db.select that for JsonAgg. I also want to be able to do things like jsonAgg({...}).orderBy(...).filter(...).as(..) In my sql queries to make it more like the rest of the ORM. (I need these orderBy and filters optionally, and I know I can just pass them in as arguments but i'm trying to keep the api similar to how the rest of drizzle would implement a feature like this. I tried extending the SQL class function like this ...

Table type

In the example below, I have an abstract class with several methods. While redefining these methods for each implementation works, I want to provide default functionality directly in the repository as a static class attribute. This way, I can override the defaults only when needed. However, I’m unsure about the appropriate type for the table attribute. Can someone help me resolve this issue? ```ts export abstract class Repo<TEntity extends { id: string }, TInsert> { public abstract find(...

Auth.JS + Drizzle ORM ([auth][error] AdapterError)

I have been trying to complete the authentication setup , but this error keeps on popping up. I have followed all the installation part from the docs and configured google OAuth, and drizzleAdapter successfully. When a user clicks on signin, it creates the correct entry on the DB (both in users and account table), but it doesn't compelete the call. I have added logs in session under callbacks, and it is not called. And the session when logged in other files (although the DB is updated) returns a null....
No description

drizzle-orm not inferring type from soft relations

Hello, I have set up soft relations to products and prices, my schema looks like this: ```ts export const PriceTable = pgTable( "price",...

drizzle-seed TypeError: Cannot read properties of undefined (reading 'length')

this is the error im getting (any help would be appreciated!): ``` /node_modules/drizzle-seed/index.mjs:131268 && !values.every((val) => val.values.length !== 0)) { ^...

`The types of '_.config.columns' are incompatible between these types` when upgrading to Next 15

driver: turso drizzle-orm: ^0.33.0 Upgraded to Next 15 and now any usage of a table results in errors like this. I have another project where upgrading to Next 15 + Neon Postgres worked fine, so I'm not sure what's going on here. I'm deliberately using 0.33 due to an issue with Turso schema database migrations being broken in anything newer, so upgrading is not really an option (exhibits the same issue anyway). Not sure what Next 15 is doing that could potentially be causing this either, seems to just be a type issue as everything works at runtime. ...

DrizzleKit won't regenerate my schemas because of index keys

Hello, I have issue with my drizzle.config.ts. I tried to regenerate it but I keep getting this error even if I remove my docker container and uninstall drizzle-kit from my package.json. Error: We've found duplicated index name across public schema. Please rename your index in either the .....
No description

drizzle queries won't resolve

Guys, I am completely stuck with something after upgrading my drizzle-orm libraru version. This is the code I am testing: import type { DrizzleConfig } from 'drizzle-orm';...

Disambiguate optional one-to-one relationship

This is a similar problem to https://discord.com/channels/1043890932593987624/1084576896039260202/threads/1254869164607143998 - but instead involves two tables, one of which has a non-nullable foreign key to the other. https://drizzle.run/my887gq5kvpp1ogl3xpoe0zh I have table A that has an id column, and table B that has a nullable reference to table A on a unique column. This is an optional one-to-one relationship, however, there is another column on table B that is not unique and should have a many-to-one relationship to table A....

How to spy on Drizzle in Vitest to throw an error

Hi, I want to spy on a drizzle call in my vitest tests and use that spy to throw an error so I can test my error handling around the Drizzle call in my code should it fail. In the past I've done things like the below in Prisma but haven't had any luck replicating it with Drizzle yet and wanted to know if anyone else has managed to do something similiar. Ideally I want to just spy on a specific call update to a table (users) like in the example below. ```...

No such column Error - Query help

I'm struggling to figure out what I would think is a very basic query in drizzle... I can do it no problem in sqlite: ```SQL SELECT ab.user_name, ai.item, ai.trait, ai.guild, ai.rarity, ai.timestamp, ab.bid_amount, ab.use_case FROM auction_items ai LEFT JOIN (SELECT item_id, user_name, bid_amount, use_case FROM auction_bids WHERE user_id = "test_user_id" AND deleted == 0 GROUP BY item_id) ab ON ai.id = ab.item_id...