Drizzle Team

DT

Drizzle Team

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

Join

Drizzle complains when I'm trying to insert into a table.

I have a schema that looks like this: ```ts export const Organization = pGtable( "Organization", {...

Is it possible to use the Query API to select many-to-many relations?

In prisma I can do this to select the entities from the "other side" of a many-to-many join: ```json export const select = { id: true, email: true,...

How can I configure `drizzle-kit introspect` to generate a schema with a schema?

I'm using this guide to migrate from Prisma to Drizzle and when I'm calling drizzle-kit introspect it generates a schema.ts file without using a pg schema. It should be obvious to drizzle-kit that I'm using schemas since I have ?schema=myschema at the end of the database connection string. How can I fix this?

Can't Push Schema to AWS Aurora - Is My Config Correct?

Hi guys! I'm moving from Vercel Postgres to AWS Aurora and I'm just trying to npx drizzle-kit push my schema but I keep getting a Region is missing error. Looking into this deeper, it looks like if aws-data-api is set as the driver, it will attempt to create an instance of RDSDataClient that requires a region to be specified. ...
No description

No matter what I try, npm run migrate defaults to my .env file. Npm run generate works just fine.

Hey, I am trying to set dynamic variable paths. When I run npm run migrate, it always defaults to my .env file and I can't find a way to change it. anyone have similar issues or know where I could go to fix this? example: ```js import { defineConfig } from "drizzle-kit"; import dotenv from "dotenv";...

construction a dynamic query builder generically ?

Ok i'm not really sure how to ask this but I'm trying to allow a user the ability in UI to build out a query builder where they can add many filters with potentially nested filters with AND/OR conjuctions. Like airtable. Anyone have any patterns how to do this? I had attempted to try to construct a mapping on the SQL operators and the drizzle functions but I can't get the types to work . ...

conflicting peer dependency when installing drizzle-orm

I am trying to install drizzle orm in a fresh install of Nextjs and have the following error presented ``` ❯ npm i drizzle-orm npm error code ERESOLVE npm error ERESOLVE could not resolve...
Solution:
I don't think there's really anything Drizzle could do to mitigate this issue, apart from splitting ORM for Native into a completely separate package... Next.js doesn't really support Native out of the box, so fresh Next projects start off with a version of React unconstrained by Native compatibility. But NPM sees that ORM has an optional peer to support Native and demands that your dependencies meet that constraint, even if your project does not use that optional peer. Solutions (any one should work): - If your project will not use React Native: - Use a different package manager with a more flexible resolution strategy (Yarn definitely handles this gracefully, PNPM and Bun probably do too)....

Database with no password

On my local machine for development, i have a psql database with no password. When i do '' for the password for db credentials, ```ts export default defineConfig({ schema: './src/lib/db/schema.ts', dialect: 'postgresql',...

onConflictDoNothing still incrementing primaryKey

I have the following ballots schema and then inserting to it via an Next.js app directory API route. I added not to do anything if there is a conflict. I thought I was doing it correctly as nothing was being inserted into the DB. However, when I inserted a new record and refreshed Supabase, I all of a sudden went from a primary key of 1 for the first record to a primary key of 8 for the 2nd record. Is there a way to not increment this primary key if there is a conflict? Am I possibly doing som...
No description

Optionally chaining joins and typescript issues.

Hey everyone, I'm currently a bit stuck trying to brainstorm how to solve the following problem and I'm sure there's an easy way to do it that I'm completely overlooking. I'm implementing a backend route for a data table where certain columns can be shown or hidden. I want my database query to only include joins of tables when a relevant column is to be shown. I'm using Typescript, Drizzle, PostgreSQL, trpc, react, tanstack table and zod if any of that is relevant....

Use COALESCE in index

How can I generate this sql:
CREATE UNIQUE INDEX "IndexName" ON "Table" ("foo", COALESCE ("bar", ''));
CREATE UNIQUE INDEX "IndexName" ON "Table" ("foo", COALESCE ("bar", ''));
When I use the following schema definition:...

Error while attempting new push

I am using AuthJS Beta (following their instructions) and basic level drizzle-orm schema setup but when I push my newly made changes into the users table I get the following error: ``` I've made a project in drizzle and I have changed my table and added new columns, when attempting to push I get the following error. Keep in mind that I already have users in my app. ...

Creating DB with schema

I am pretty new to drizzle and try to follow the documentation. I found that you can initiallize drizzle with a schema like so: ```typescript import {drizzle} from "drizzle-orm/mysql2"; import mysql from "mysql2/promise";...

Unknown Option

I am currently using bun on windows and I get this error when trying to make a migration. Anyone able to help me solve this?
No description

Custom type is unknown on Drizzle Studio

Hello, I have created a custom type to store my database salt like this: ```ts...

Password authentication failed when trying to run migration postgresql

When i run this command "db:migrate": "tsx src/drizzle/migrate.ts" i get the below error ``` susant@susants-mint:~/elixer$ npm run db:migrate...

Return object instead of an array when inserting object

How can I get the insert statement to return the inserted object instead of an array, when I am only inserting one row? const insertedRole = await db.insert(role).values(insertRole).returning();...

PostgresError: column "content" of relation "post_table" contains null values

I had dropped the column in the past but now I want to restore/create it, it's also coming in the scripts as ALTER TABLE "post_table" ADD COLUMN "content" text NOT NULL; but I am getting this unexpected error. And in Drizzle-studio too I am not seeing a table named content Any help would be greatly admire🙏 https://github.com/Boby900/yogurt...
No description

Drizzle config file unable to locate env file

I'm trying to create a SvelteKit app, with Drizzle and PostgreSQL using this tutorial: https://sveltekit.io/blog/drizzle-sveltekit-integration and the SvelteKit documentation for env import modules https://kit.svelte.dev/docs/modules#$env-static-private I've created a drizzle.config.ts file in my root containing the code he gives, and a .env file in my root containing some variables. I'm getting the error Cannot find module '$env/static/private' or its corresponding type declarations. ts(2307) when I try and import the env file with import { env } from '$env/static/private'; and Type '"pg"' is not assignable to type '"d1-http"'.ts(2322) on the drizzle driver declaration line. It seems that typescript is unable to find the local file perhaps? Any idea what might be causing these errors?...