Drizzle Team

DT

Drizzle Team

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

Join

With Query mode, is possible filter by a related table?

Is possible using db.query to filter (where) using a related table? Example: ```js const users = await db.query.posts.findMany({...

Composite Primary Key?

In the latest versions, what would be the correct third argument of a pgTable for composite primary key? '''(t) => [ primaryKey("ContactToCompany_contactId_companyId").on( t.contactId,...

Best column type for storing a small WAV file in Postgres

I have a small audio WAV file that I'd like to store in a column. What column type is best suited for that? I'm using Neon db Postgres. Note: I'm aware that I could store it in a storage like S3, but given the file is very small, I'd like to explore storing it in Neon....

Rollback not happening on tx.rollback() [PG DRIVER]

```ts export async function createRestaurantMenuMutation({ label, type, availabilityDate,...

Drizzle studio not recognising new schemas

Hi guys When I was learning Drizzle I. Came around a problem Where I have a written a new schema After recognizing my Mistake in previous Schema, but the drizzle studio Does not recognising the new schema and always showing the the table on context of old schema? Even I have regenerated the schema and And pushed the latest migrations to my database , but still drizzle Studio Show me the schema with context to old schema...

Drizzle & Neon low latency

I have my app server deployed on railway (FRA) and a neon DB deployed in FRA as well. My latency from App -> DB (with drizzle) is about 800ms while when using the neon Console directly I have a latency of about 45ms. Where does this overhead come from?...

TypeError: client.migrate

I am getting this error TypeError: client.migrate is not a function with Kysely + Drizzle Kit + Turso + Bun + Nextjs when I drizzle-kit push. My config (in the root of nextjs project): ``` import { defineConfig } from "drizzle-kit";...

Issues Using RLS with Supabase Through Drizzle

Hi everyone, Does anyone know how to use RLS with Supabase via Drizzle? I was really excited to see that it's finally supported, but unfortunately, it’s not working for me. After migrating the table, I added .enableRLS()—this part works fine, and I can see on the Supabase dashboard that RLS is enabled for that table....
No description

SQLite insert schema does not include nullable columns?

Hi, I am just tring out Drizzle with SQLite, but am running into some weird problem. I created a table like this ```export const products = sqliteTable( "products_table", {...

[Postgres] PostgresError: type X already exists.

PostgresError: type "media_types" already exists
PostgresError: type "media_types" already exists
I have SQL like this: CREATE TYPE "public"."media_types" AS ENUM('image', 'video');--> sta ...

Drizzle-kit not working as expected

If there is a file xyz.ts and it currently has one table and if I use npx drizzle-kit push it runs sucessfully I add one more table to same file and use the command again it throws error ```ts [itsmishra@Rajat ayanami]$ npx drizzle-kit push No config path provided, using default 'drizzle.config.ts' Reading config file '/home/itsmishra/ayanami/drizzle.config.ts'...

Postgres tables with same name but different schema

I have three users tables, each in different postgres schema. They have 3 columns in common: email, createdAt and updatedAt. When I try to make a relational query where I fetch a token with the user relation, the type of the user contains just those 3 columns, instead of all columns of that specific users table (image attached). Seems like it is an intersection of the types of those 3 users. Seems like the problem is that a relation is defined as: ``` Relations<"users", { ... }>...
No description

The signature with pgTable is depreciated.

The pgTable function with the callback function is depreciated? And If i remove the second argument to the function(the callback function), the depreciation message disappears.
No description

is it possible for a join table to have one of the relations reference a composite key?

i have the following: 1. contacts table - userId // this references the user's id per clerk (otherwise, this would really be basically a join table) - contactId // this references the contact's clerk user id - pk is composite of the aforementioned ids...

Can't migrate with pgPolicy and pgRoles

For context, this is my current setup, I cannot drizzle kit push to my schema and getthing an error saying: error: role "BODYSHOP_ADMIN" does not exist Roles.ts ```typescript...

Supabase SSL - ENAMETOOLONG when adding sslrootcert to dbCredentials url

I'm trying to connect to my supabase with ssl-enabled using drizzle-kit but I keep on getting ENAMETOOLONG. I'm encoding the certificate into the connection url, but it seems like I'm reaching the limits of path length. My code is literally the same as was posted by budivoogt: https://github.com/orgs/supabase/discussions/18710#discussioncomment-10614735...

I'm trying using $count, and it giving me fieldAlias missing. What should I do?

I'm on drizzle-orm 0.36.1 and drizzle-kit 0.28.0. My schema is something like below. For note, its oversimplified over my project. ```js export const item = pgTable(...
No description

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');...