Drizzle Team

DT

Drizzle Team

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

Join

Type error in 0.33.0

``` export const cities = pgTable("cities", { id: serial("id").primaryKey(), name: varchar("name", { length: 256 }), });...

Types aren't being inferred properly

I have the following schema. ```ts export const taskFolders = pgTable('task_folders', { id: uuid('id').primaryKey().defaultRandom(), taskId: uuid('taskId').references(() => tasks.id, { onDelete: 'cascade' }),...

using drizzle queries with aws postgres db

this is how the db is defined but db is of type : AwsDataApiPgDatabase<Record<string, never>> with drizzle queries type requiremet is export const auroraDB: AwsDataApiPgDatabase<Schema> so I am able to do db.select but not db.query.table.findMany Please Help...
No description

Drizzle unit test (Vitest)

i m trying to use a second db(db2) for my unit test but its still keep writing into db1 anyone can gv me some guidance or help please? ``` export const createNewLocationRow = async ( createNewLocationPayload: ICreateLocation...

how do i insert an array into db

i have a json array ``` [ { column1: text,...

db.insert is not reading all properties from my schema

I'm trying to insert a value into a table with several relationships, but Intelissense reports an error and the value is not inserted
No description

Can I Skip Code-Based Migration and Just Use drizzle-kit migrate?

I’m using Drizzle ORM and noticed there are two ways to run migrations: using the drizzle-kit migrate command and the code-based approach (migrate function). Do I need both, or can I rely solely on the drizzle-kit migrate command to handle my database migrations? What even is the difference between the two? ...

The requested module 'node_modules/pg/lib/index.js' does not provide an export named 'Pool'

I try to to setup the drizzle with nuxt but I have an error. All the structure I make down above. Run the npm run dev and the error appear... Error ```...

Cannot update / insert default value

I have some fields like date and enums which have defaultNow() and default(), i cannot update or insert to these fields , i saw someone say use strickNullCheck, but it fricks up my whole project , im using nestjs

Supporting multiple engines in one app that uses db migrations

Hi, I am mid-execution of my project which I'd like to release as Open Source. With this in mind, I want users to be able to choose their db - e.g. use SQLite on Cloudflare, postgres on Kubernetes deployments etc. This leads me to the following assumptions: 1. The application must be able to update both schema and data safely between versions - for this schema migrations sound great, but......

Can't push without dropping tables on turso

Hi! No matter what i change in my schema, i get errors. Only if i drop all tables. i can successfully push again. Even just simple changes to schema doesn't work....

Possible to have multiple onConflict ?

Hi, Would it be possible to have multiple onConflictUpdate statements ? For exemple "if conflict on ID do that" and "if conflict on clientId do that instead" ?...

referencedTable error when querying

Hello! I'm trying to define one to many relations between the tables. While it works for most of the tables, I cannot think of why it fails for SRSCards. I created a very minimal and complete drizzle.run: https://drizzle.run/y2ztrp5ylzvj18klf8kxf932 The error in the playground is different, as locally I get:...

Migration Errors

Hi all, i am trying to make a migration to a database in Turso using drizzle. However i am blocked in two issues. - The first is because when i do some changes on the schema the major of the times the migration presents the following message: " SQLite does not support xxxx out of the box, we do not generate automatic migration for that, so it has to be done manually" - The second one is when i try to apply the migration i got stuck in these errors: SQL_MANY_STATEMENTS or SQL_EMPTY_STATEMENTS...

Can't get relations from db.update

This is the code I use to retrieve a user: ```const validUser = await db.query.user.findFirst({ with: { buildings: true },...

Query syntax with Turso (in NextJS context)

Hey there, I guess I'm missing something somewhere. I'm trying drizzle with libsql driver. When used locally with sqlite database, everything is working fine, but if I want to connect to my turso database, I can successfully get data using the classic ORM apis (db.select().from(tests).limit(1)?.[0]), but I can't get relational query syntax to work (db.query.tests.findFirst()). It always return undefined. ...

Is there a way to reference multiple fields in a many to one relation?

I have this schema ```ts export const users = pgTable('users', { id:uuid('id').primaryKey().notNull().defaultRandom(), })...

Create a Query and insert into sql`` template

TLDR: How do I take a query (such as PgSelectBase) and put it inside an sql template? I want to use the query builder to create a query that I will then put into a (Postgres) TEMPORARY TABLE to allow me to query it twice and not have to save on performance. I have got the following:...

Where clause on 'with' in findMany

```export const getOrgsByMembershipList = cache(async () => { const user = await getAuthUser(); if (!user) { throw new Error("User not found");...

Expo app + drizzle-kit migrations and enabling journal_mode = WAL

Hey, I'm pretty new to SQLite and drizzle-kit. I've read that enabling WAL journal mode on your SQLite DB is preferred for performance. I thought it made sense to create a custom migration npx drizzle-kit generate --custom with this statement in it: PRAGMA journal_mode = WAL; but when I deploy to my device (Android phone) the migration fails to run. Is this not the way I should be doing it?...