Drizzle Team

DT

Drizzle Team

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

Join

Is it possible to tell drizzle which schema to use on the database?

I'm trying to introspect a postgres database with multiple schemas but I want only one of them. Currently drizzle is including only the public schema in the introspect which ends up not being what I want....

Has anyone done a custom `bytea` column type for postgres?

I'm trying to move our work project to drizzle and the first thing I encountered was the missing bytea column. There was an open issue for it in the github, so I was wondering if someone has already implemented bytea so that I can reuse it πŸ˜„...

What does this section of the docs mean?

Under the docs for indexes and constraints it says that drizzle kit only supports index name and on() param. What does this mean? Would the following not work with drizzle kit then? ```ts export const users = mysqlTable("users", { clerkID: varchar("clerk_id", {length: 255}).notNull().primaryKey(),...

Schema not added to FK constraints

Hi! πŸ‘‹πŸ½ I'm trying to use drizzle with MySQL. I have a mysqlSchema that I made and then am trying to create a FK but the generated SQL doesn't include the schema. ```ts...

Drizzle npm package not working

Hey guys, I have tried to create an npm package with my drizzle schema and types but when installing it and importing I keep getting this```ts Error: node_modules/drizzle-orm/db.d-a6fe1b19.d.ts:521:15 - error TS2515: Non-abstract class 'PgSelect<TTableName, TSelection, TSelectMode, TNullabilityMap>' does not implement inherited abstract member 'getSQL' from class 'PgSelectQueryBuilder<PgSelectHKT, TTableName, TSelection, TSelectMode, TNullabilityMap>'. 521 declare class PgSelect<TTableName extends string | undefined, TSelection, TSelectMode extends SelectMode, TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'> : {}> extends PgSelectQueryBuilder<PgSelectHKT, TTableName, TSelection, TSelectMode, TNullabilityMap> { ~~~~...

Do we have to add enums to the migration manually?

I have the following in the my schema: ``` const membershipRoleEnum = pgEnum('membership_role', [ 'GUEST',...

Getting Started With Drizzle And Had A Few Questions

Hi! I'm getting started with drizzle after having been a long time Prisma user. I had a few questions about Drizzle as I'm getting started: 1. Is there a "cuid()" type of functionality where instead of using a integer key I can use a CUID? 2. How can I set non-id fields to be unique (In prisma, this was doable with the @unique)? ...

What's the overhead (if any) of using the new relational api?

I love the new relational api but I am wondering about the performance overhead

Multi-File Schemas

I think I posted this (https://discord.com/channels/1043890932593987624/1056966312997429278/1117546028787306557) on the wrong channel. Please advise. Maybe Admin can move it?

UUID insted of ID

Hi, is it possible to replace the "serial" column with UUID generation instead of the standard auto-increment when creating a schema in MySQL?

Dynamic where query

With a relational query, is there a way to change the where query based on user input? In Knex.js, we could do something like this: ```knex('questions')...

Planetscale migration error

Hey guys, I was just trying drizzle with planetscale for the first time and I end up having this issue with migrator using planetscale serverless driver with admin privileges,...

Drizzle-kit can't load env file via t3-env

I'd like to use t3-env to validate my env variables in my Drizzle config file. I've tried importing t3-env in the config.ts file, but I'm hit with the error SyntaxError: Cannot use import statement outside a module in env.mjs, which I find odd since it is explicitly marked as an ES module. Other than this, t3-env works fine with drizzle-orm. Full Error: ```js Reading config file 'F:\Projects\PROJECTNAME\drizzle.config.ts'...

I need some guidance on joins

Hi I am using joins because it makes the most sense in my application, I was gonna try out the relations api but I want to work on my sql skills as well, so I have this schema and I am trying to understand how to get all teh tables returned in a single query here is the schema ``` export const items = pgTable('items', { id: uuid('id').primaryKey()...

Best way to run safe raw queries when only having access to the table name?

Hey I'm working a Drizzle adapter for a library. The Adapter API only has access to the db Drizzle instance and the table name, what's the best way to perform a SELECT * FROM table given only those two parameters? The sql operator works by passing not the table name, but the schema (which I dont have access to) so I tried sql.raw but it doesn't escape variables. I could escape them manually, but maybe there's an easier/better way.

InferModel including relations?

Hi, How do you use InferModel to obtain a type that includes relations? The results for an executed query has the inferred types but I'm not sure how to infer the type more generally?...

How to declare 1-to-0:1 relation between tables?

As the title says. The existing helper one seems to be for 1-to-1 relations. Thanks!...

How to suppress 'relation "x" already exists, skipping' logs during migration?

It's rather annoyingly clogging up my terminal, I know the tables already exist, but there doesn't seem to be a (documented) way to either suppress the messages or check the database version (and therefore not migrate if the DB is up to date). Any current way to do this?

many to many doc example

hello, i want to know how its possible to get the same value in the doc for many to many ?https://orm.drizzle.team/docs/rqb#include-custom-fields

Custom Function to Transform Subqueries is missing types

πŸ‘‹ So I am trying to write helper functions that are able to transform subqueries. The goal is to work around not having access either RPC's nor subqueries in select statements. A bit more context in this discussion: https://discord.com/channels/1043890932593987624/1085153354340114563/1116875363193192470 However using something like ```ts function transformWithSubquery<T extends WithSubqueryWithSelection<ColumnsSelection, string>>(subquery: T) {...