Drizzle Team

DT

Drizzle Team

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

Join

Querying DB returning same row for two different userIds

Hi everyone 👋 , I am running into an issue where I have two different users logged in (one on Chrome and one on Safari) to test multiple users logging in at once. One user has submitted a ballot and the other has not. However, with the one that has not voted, hasVoterVoted is returning true AND getUsersVote is returning the vote of the other user. I logged out user.userId and they are different in each call... So why would drizzle/supabase be returning the exact same information for two different userId? My guess is due to the eq(model.userId, user.userId) && eq(model.year, year) && eq(model.week, week) because if I remove the check for year and week in the hasVoterVoted, it returns false for the user who has not voted....

Array of Objects

Hello, I wanted to know how can I create an array of objects in a table. Like ```js fields: { name: string,...

nesting db calls in transactions without using the callback argument

What is the point of the trx argument when calling db.transaction()? when using raw sql, a transaction looks something like ```sql BEGIN TRANSACTION...

How to add a new column to an existing table

Right now I have just been testing locally with Drizzle, Supabase, and Next.js... I created a schema for a table called "ballots" (see image). However, I realized that I am missing a column 🫠 🤦‍♂️ which is the one that is commented out in the image. Now what I have been doing is deleting the tables in Supabase along with the supabase/migrations folder and then running the generate and migrate scripts... 😬 I feel like that is a bad thing (maybe not?)... Since I am just testing and none of th...
No description

mysql 5.7 support?

Hi drizzle support mysql 5.7? When i use drizzle query join (with). Drizzle translate to lateral join and lateral join not support for mysql <8

TypeError: Cannot read properties of undefined (reading 'columns') - SQLite TursoDB

``` pnpm db:push
project@0.1.0 db:push C:\Users\migue\project dotenv drizzle-kit push...

__old_push table

Hi, I just ran a pnpm drizzle-kit push:sqlite to push some schema changes to my turso db. I basically added a single column to a table with a default value. I then removed the column and pushed again. Now I have a new column __old_push and it seems I'm stuck in an intermediate state. Is there a fix for this?...

Drizzle with self hosted supabase not working

Hello, I created a self hosted instance of supabase on my machine. I am also using nextjs. Because of that I need to be using neon driver to connect to supabase instance. This is how I create connection ``` import { Pool } from '@neondatabase/serverless';...

Create a view with Drizzle

Hi, need some help to understand how i can create a view with Drizzle. "drizzle-orm": "^0.31.2", "drizzle-kit": "^0.22.6", export const wf_users_in_private_view = pgView("wf_users_in_private_view", {...

D1 Failing Migraton on Prod

``` import type { Config } from 'drizzle-kit'; export default { schema: 'src/lib/db/schema.ts',...

snapshots from v6 to v7

migrations/meta/0000_snapshot.json is not of the latest version, please run "drizzle-kit up" why do i have to update my snapshot to version 7? i am already on version 6 when running this nothing changes...

Error in DB update because of Date

For some reason drizzle is complaining that the property birthDate is not a Date because it cannot run the .toISOString() method on it. But I'm sure this is not the case.... I really don't know what is going on. birthDate: timestamp("birth_date", { mode: "date" }),...
No description

How to do an UPDATE with a JOIN in Drizzle ORM?

Something like this https://stackoverflow.com/questions/7869592/how-to-do-an-update-join-in-postgresql I have this schema where I want to do an update on the "user_usage" table, but only if users.subscriptionId is a certain string or in a set of string values ....

disable drizzle date conversion to local

I have a timeFrame that is getting pulled from database at utc 0 and i want to keep it at utc 0 , drizzle seems to convert it into local time during the query, so i want to disable that so that i can pull the timeframe as is, did not find anything in the docs this is database at utc 0 and at server after co...
No description

How to dynamically set a row value using data from a JS object? (onConflictDoUpdate)

I am: - Checking if a row already exists - If it doesn't: Insert the data array's object - If it exists: Update the price column - The issue is I'm not sure how to set a row to the relevant object in my data array ```js...

Does Drizzle support using INSERT statements in a WITH clause?

I've attempted to write the following postgres query with Drizzle multiple ways, but ultimately haven't found a suitable replacement for the templated SQL: ``typescript const query = await db.execute(sql WITH "new_thread" AS ( INSERT INTO...

drizzle-kit defineConfig no "pg" driver available.

There seems to be no type for "pg" in the driver field of defineConfig in drizzle-kit. ```ts import { defineConfig } from "drizzle-kit" ...

Multiple files schemas with query to Access data

I want to use query but I heard you have to import every schemas to use query. Is there a way to import every files in that folder instead of doing this below: ``` import * as schema1 from './schema1'; import * as schema2 from './schema2';...

Migrations taking the first snapshot

I'm running migration like how it says in the docs, but for some reason it keeps trying to use the first migrations file generated even after running generate ```ts import "dotenv/config"; ...
No description

NeonDbError: Error connecting to database: fetch failed

i get this ^ error on my laptop which runs linux but not my desktop which runs windows. how do i fix it?