Drizzle Team

DT

Drizzle Team

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

Join
HIAHello, I’m Alastair!5/3/2024

Delta Updates(somehow)?

Hi y'all! I have a dataset of CSV files(some large enough to not fit into memory). I also have a schema set up to insert that data into Cloudflare D1. A fresh copy of this dataset is pulled from an external API once a day, though I do not know whether anything has changed, whether it is only a single file, or even if it is just a single row in a large file that has changed. Is there some way for me to only push updates for rows/fields that actually need to be changed, minimising the number of operations I need to do against the DB?...
MMinato5/3/2024

(question) onConflictDoUpdate set columns values (Postgresql)

I have a question in "onConflictDoUpdate" how can I update columns values if i want to use the old value and add on them some other informations ```typescript let newvideoId = "d000" return await db...
Rrevskill5/3/2024

Problem with AT TIME ZONE

When running drizzle-kit studio, I got error with following generated schema file (from supabase):
createdAt: timestamp("created_at", { mode: 'string' }).default((now() AT TIME ZONE 'utc'::text)),
createdAt: timestamp("created_at", { mode: 'string' }).default((now() AT TIME ZONE 'utc'::text)),
```js...
MMatusko1675/3/2024

possible to have more than one migrate folder or more drizzle.config.ts

hello guys i want ask if its possible to have more drizzle.config.ts files or somehove separate more schemas and more migrations becouse we are using plugin structure so we need separated migrations and schemas with unique names?
Nnr77515/3/2024

Columns are being stringified at random

Hi everyone. In my JSON response object , some numeric fields are being turned into strings, whereas otehr fileds are kept in their oiginal numeric format. Why? Is this a config problem? Can I do somethign about it? The schema is correctly typed, but when I fetch some fields get turned into text whereas others do not. Thanks in advance for any help !...
Solution:
What is the exact column type you're using for price? - numeric and decimal (exact precision) are input/output as a string - real and double precision (variable precision) are input/output as numbers...
Sstumpykilo5/3/2024

New enum values must be committed before they can be used

I have some INSERT statements in a couple of my migrations that use an enum that I have created in preceding migrations. When I go to run all of my migrations when creating a new instance of my db I receive the following message: error: unsafe use of new value "MY_ENUM" of enum type followed by the hint of New enum values must be committed before they can be used. What I did to resolve is add COMMIT; immediately after I add the enum in my preceding migrations. ...
Xxxxxx5/3/2024

Create slug based on title field.

I currently have a product schema that has title field that is a nonNull text. I want to create a slug that is automatically generated. My current approach to this is using the .$defaultFn((title) => createSlug(title)) but I am struggling to find a way to reference title in the defaultFn. Is there some way to do this?
SSenna5/3/2024

Problem with generating migrations

Hi, i have made a question on stackoverflow: https://stackoverflow.com/questions/78423964/generate-drizzle-migrations-in-nodenext-project Can someone help me with this issue? Thanks!...
CGClancy Gilroy5/2/2024

MySql 5.7

Hello! I've been trying to get this going for a few days now. I've been trying to query data with relationships in mysql 5.7 using drizzle. What I know so far using mysql2 driver. - Normal mode doesn't work because lateral joins are not supported in mysql 5.7....
Nnr77515/2/2024

( sql question ) How do you join full tables with select columns from other table?

Hi everyone. I'm new to Drizzle. I have this TypeScript function: ```typescript export const fetchAllServicesWithProfiles = async () => {...
Solution:
select({id: services.id, …}).from(…).innerJoin(…)
Ssmiley5/2/2024

Cannot migrate/push after adding column to sqlite table

I'm new to Drizzle, so I assume I'm just doing things wrong. I have a sqlite db with a bunch of tables. If I add a single integer column to a table, then try to drizzle-kit push:sqlite I get the following error : ```
drizzle-kit push:sqlite...
Hhunt5/2/2024

Help building queries based on multiple conditions from an array of objects

Hello, I'm having trouble formulating a query that will match rows to multiple conditions at the same time. Suppose I have an array of objects like : ```...
LLloyd5/2/2024

Postgres.js type error string/date

I'm running the following where clause in a select query: ``` .where( and(...
Xxxxxx5/2/2024

add a prefix to UUID?

I am wondering if there is a functionality where I can add a custom prefix the uuid's. These uuids would be used as a pirmary key in my case. The end result would be something like this: product_9B4F49D6F35C49FEA0dCC579A8ED4755...
EEntsllor5/2/2024

[BUG?] Handling Postgresql schemas when using enums

"drizzle-orm": "^0.30.10" Hello. I have a simple table with a status column ```ts export const BaseSchema = pgSchema(settings.DB_SCHEMA_NAME); // DB_SCHEMA_NAME=my_schema export const statusEnum = BaseSchema.enum("version_status", values);...
Hharshcut5/2/2024

Help needed for Nested Query

For this example, I have 4 tables - user, podcast, episodes, and bookmarks. - bookmarks table has two columns - userId and episodeId - each podcast can have multiple episodeIds, each episode can have only one podcastId (one to many) - each user can bookmark multiple episodeIds, each episode can be bookmarked by multiple userIds (many to many) ...
Bbigman805/1/2024

Typescript performance in larger codebases?

Hey, I've been using drizzle with small projects, but now I'm thinking of migrating a larger codebase to drizzle. This codebase connects to a database with over 500 tables and consists of over 300k lines of code, most of which is SQL queries made with Knex. However, I'm a little concerned about typescript performance degrading at that scale. I know a common recommendation is to break up the code into smaller pieces, but unfortunately that won't be possible right now. I started incorporating Kysely into this codebase, but type checking and autocomplete became much slower. Looking at the way drizzle works I'm hoping that it could put less strain on the type checker and be more viable. Can anyone with experience using drizzle at that scale let me know how the typescript experience and overall type-checking performance is for them?...
DDawson5/1/2024

multiple dbs, multiple drizzle client, not registering as multiple dbs

Hey all, anyone know why apiDb shows up as not working? Originally when I had keys schema imported under apiDb, it worked perfectly fine. db and its table works fine. Generated using t3 index.ts: https://paste.learnspigot.com/dicuhehiri.typescript api-schema.ts: https://paste.learnspigot.com/guqayuviwe.php schema.ts: https://paste.learnspigot.com/enufuvujuq.php...
KKeith5/1/2024

Setting triggers with drizzle

Hey, good day guys. I'm a web developer who recently picked up mysql and drizzle. Going through the drizzle docs now and I was wondering if there was a way I could set stored procedures and triggers in my sql database using drizzle?
Next