Drizzle Team

DT

Drizzle Team

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

Join

Can i use "uniqueIndex" for that?

Hi, I was just wondering if ```export const contactToCompany = pgTable( "ContactToCompany", {...

TypeError: db.execute is not a function

import { drizzle } from 'drizzle-orm/better-sqlite3'; import Database from 'better-sqlite3'; const sqlite = new Database('sqlite.db'); const db = drizzle({ client: sqlite }); const result = await db.execute('select 1');...

Automatically convert binary to string

```typescript export const table = mysqlTable( 'table', { id: binary('id', { length: 16 }).notNull().primaryKey(),...

Drizzle-kit push - pgPolicy ignores using configuration

Policy: pgPolicy("Users can view their own active organization memberships", { for: "select", to: authenticatedRole, using: and(...

column is of type date but expression is of type text

So, I was trying this and it resulted in an error:
column \"date_of_birth\" is of type date but expression is of type text
column \"date_of_birth\" is of type date but expression is of type text
It happened when I tried updating multiple columns of multiple rows of a table. It doesn't happen when multiple columns of a single row are being updated. What causes this? I asked another person and they said that it's not necessarily a postgres issue and probably has somethi to do with drizzle orm....

Do prepared statement names matter?

Should we make sure that the names of prepared statements are unique in any way? If so, unique globally or within a block scope? For example, is this a problem within the same block? ```ts const prepared = db.select().from(customers).prepare("statement_name");...

Bun:SQLITE error with drizzle

trying to run drizzle studio and push changes using drizzle kit but having this error ``` Cannot find module 'bun' Require stack: - C:\projects\tasks-api\src\env.ts...

How do I get types for relationship queries?

``` // Users table export const users = pgTable('users', { id: serial('id').primaryKey(), email: varchar('email', { length: 255 }).notNull().unique(),...

Filter based on join data

Hi, would it be possible to query a list of student and filter by the name of its coach. The data is <student>.coach.fullname where coach is added as a with join. I would like to get every student that have a certain coach.

Using relation columns in where clause (Drizzle playground provided)

I have a one-to-one relationship with a schema defined like: https://drizzle.run/uwkkt8l10cgp5okr1r41tjfu When I run that query, I get the following error column agent.deleted does not exist. Why can't you reference relation columns in a top-level where clause? Is there a better way to do this without using the select API with joins?...

StatementTimeoutException: Request timed out

Hey! So I'm using SST v2 on my project. As database I'm using RDS Aurora (https://v2.sst.dev/databases#rds, https://v2.sst.dev/constructs/RDS) with PostgreSQL engine. I have followed the guide from SST docs and take a look on Drizzle docs too (https://orm.drizzle.team/docs/connect-aws-data-api-pg, https://orm.drizzle.team/docs/perf-serverless). But recently I noticed that I have run into StatementTimeoutException: Request timed out issue. I'm getting this error in SST console: `StatementTimeoutException: Request timed out at de_StatementTimeoutExceptionRes (file:///var/task/packages/functions/src/api/permissions/get-user-permissions.mjs:62242:21) at de_CommandError (file:///var/task/packages/functions/src/api/permissions/get-user-permissions.mjs:62064:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)...

Self-referencing many to many relation

I've been trying to point some interfaces to similar interfaces using the following code: ```ts export const interfaces = createTable( "interfaces",...

Using inferred schema types in Next.js client components, 'server-only' breaks Drizzle Studio.

Im working with Next.js 14 app router. I'd like to use Drizzle's inferred types across my application, including client components. Schema: ``` import "server-only";...

How to set PRAMGA for Sqlite

Really not sure how this would be done here. Some of them are permanent but some need to be set on every connection. in my example something like: PRAGMA foreign_keys = ON; PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;...

Error: Unknown column 'c.GENERATION_EXPRESSION' in 'field list'

I have some error when start run drizzle-studio i just follow https://orm.drizzle.team/drizzle-studio/overview with bun, then bunx drizzle-kit studio. I'ts was opened to https://local.drizzle.studio/ but i got the error like this...
No description

Using drizzle postgres with trpc in Next.js app

I'm getting the following error with the below code: Module not found: Can't resolve 'dns'. For some reason, my Next.js app is trying to load drizzle on the client where it doesn't have access to Node modules. Has anyone ever run into this before? ```ts import { publicProcedure, router } from "../trpc";...

Cant get custom type to work with default value

I made a custom type for the interval type in postgres default values keep writing [object Object] to the migration file regardless of what I output in toDriver...
No description

Cannot read properties of undefined (reading 'endsWith')

Y try to push this in my supabase database
export const user_provider_topics = pgTable( 'influencer_topics', { uuid: uuid().defaultRandom().primaryKey().notNull(),...

How to select a subset of fields from a JSONB?

I'm using Postgres and can't figure out how to select a subset of JSONB fields? Is this supported yet?