Drizzle Team

DT

Drizzle Team

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

Join

New neon http driver not working with pooled connections

is the new { drizzle } from "drizzle-orm/neon-http" not compatible with pooled connections? Getting error when I do:
const pool = new Pool({ connectionString: env.DATABASE_URL });
export const db = drizzle(pool);
const pool = new Pool({ connectionString: env.DATABASE_URL });
export const db = drizzle(pool);
...

Postgres functions

Hey, I'm migrating a ton of postgres raw sql into using drizzle ORM. Is there any sort of setup for migrating sql functions? I have a couple dozen sql functions to convert. Didn't see anything in the docs but thought i'd ask

Query issue - Syntax error at or near "$1"

Hello, I currently got this error recently: PostgresError: syntax error at or near "$1" This is the query i am trying to make. Note that this worked fine very recently. ...

Cannot drop index 'idx': needed in a foreign key constraint

So I had this table with its migration in the database: ``` export const userProfile = mysqlTable('user_profile', { id: int("id").primaryKey().autoincrement() userId: int('user_id'),...

how to use insert with select in drizzle?

```sql INSERT INTO your_table (column1, column2, column3, category_id) SELECT column1, column2, column3, new_category_id FROM your_table WHERE category_id = old_category_id;...

Using LiteFS (fly.io) with Drizzle

Hello, I was wondering if there's an example project for integrating LiteFS with DrizzleORM. This project seems very out of date (drizzle-orm: 0.12.0-beta.23). If you try and install the required drizzle-orm-sqlite npm says it's deprecated and has been merged into the main repo. https://github.com/drizzle-team/drizzle-flyio-litefs ...

NextJS Build Parameter xxx implicitly has an 'any' type.

I'm trying to build my TurboRepo NextJS app but all my trpc endpoints return any when building, VSCode autocomplete works fine. Any idea what I'm doing wrong?

foreign key constraint cannot be implemented

/Users/daniel/Documents/Repos/Thatch/thatch-web/node_modules/.pnpm/[email protected]/node_modules/postgres/cjs/src/connection.js:771
const error = Errors.postgres(parseError(x))
^
PostgresError: foreign key constraint "users_to_posts_user_id_users_id_fk" cannot be implemented
/Users/daniel/Documents/Repos/Thatch/thatch-web/node_modules/.pnpm/[email protected]/node_modules/postgres/cjs/src/connection.js:771
const error = Errors.postgres(parseError(x))
^
PostgresError: foreign key constraint "users_to_posts_user_id_users_id_fk" cannot be implemented
...

Drizzle-zod Include Relations

Hello, I was wondering if drizzle-zod includes support for relations, and if so how I can include them. Thanks!...

Create database if not exists

Is there a way to have create a database if it not exists? After i create my schema and a run the first migration, i would expect drizzle to create a database that's specified in my connection string if it doesn't exist

[solved] One to many relation not working

I get the error "There is not enough information to infer relation" Here's (part of) my code ```ts...

transaction not running if previous transactions fail

I have ultiple transaction in my code, inside a single try/catch. If a transaction fails, any transactions after it are never executed, despite them not being nested/connected in anyway.

How do I use Drizzle both locally in node and deployed on Vercel Edge?

I'm having some trouble with Drizzle + Postgres, deployed to Vercel. I can either get it working when deployed to vercel edge with my db connector like: ``` const connectionString = this.env.get("DATABASE_URL") as string; const pool = new Pool({ connectionString }); const db = drizzle(pool);...

Cosmos DB PostgresSQL Support?

I am wondering if anyone has got Drizzle to work with Cosmos DB postgres? if so, any big issues? Do you recommend it if you prefer cosmos db vs planetscale and other services?

Proper Way to Deal with Migration Failures and Rolling Back?

So I added an Enum and made a few minor changes and generated 3 SQL files. But when running a migration I got the error ```bash node:internal/process/esm_loader:97 internalBinding('errors').triggerUncaughtException( ^...

Compare enums in select

I want to compare enum from my offer schema with query parameter (that is basically string). export const offerType = pgEnum('type', ['SEARCH']); query used in where statement: eq(offers.type, query.type)...

[Relational Queries] Nullable one-to-one relationship

Hey y'all. I'm using the relational queries feature and have a one-to-one relationship between these two tables. ```ts export const teamsT = mysqlTable("Teams", {...

union or union all in drizzle orm?

SELECT 'meal' as "type" ,count(*) from meal where user_id=''
UNION ALL
SELECT 'deposit' as "type" ,count(*) from deposit where user_id=''
SELECT 'meal' as "type" ,count(*) from meal where user_id=''
UNION ALL
SELECT 'deposit' as "type" ,count(*) from deposit where user_id=''
...

Can't import as ESM from drizzle-orm/pg-core

Can't import as ESM from drizzle-orm/pg-core in express app

Transaction rollback error catching

I'm using drizzle with TRPC and want my api to give detailed reasons for a rollback. However tx.rollback() throws a TransactionRollbackError, which means the TRPC error is never thrown (i think). This means the client sees an error with message "Rollback", which isn't super descriptive. ```ts await db.transaction(async (tx) => { ...some logic...