Drizzle Team

DT

Drizzle Team

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

Join

use constant in between operator

Hello guys, Is there any way to use constant in between filter instead of column?...

Type error: Could not find a declaration file for module 'drizzle-kit'.

Any idea how to fix this problem? I try to run this: npm i --save-dev @types/drizzle-kit: npm ERR! Cannot read properties of null (reading 'matches')...

Typescript error that doesn't make a whole lot of sense when calling db.select or db.insert

This is my account model ``` export const accounts = mysqlTable("accounts", { id: nanoid("id", {}).primaryKey(), userId: varchar("userId", { length: 25 }),...

Are default values not transferred over via drizzle-zod?

It seems like when I use a default([]) in my schema file that when I create a Zod object, I have to re-do the defaults?

Replace on Insert

I can see that there is a .ignore() option added to insert, but is there an equivalent .replace() or someway to flag it in the code? I'm doing an insert many by passing through an array of values (e.g. await db.insert(ActivityTable).values(values);) which is effectively an over write of existing data as well as new data...

Is there a way to modify the select() on an existing query ?

Let's say I have this query that I pass to a function
const query = db.select().from(myTable)
const query = db.select().from(myTable)
...

The inferred type of '<tableName>' cannot be named without a reference to '.pnpm/[email protected]

I'm trying to use the drizzle-zod but I keep getting this error... Any idea on where it comes from ? Thank you !...

Migration failure on fresh DB

I'm currently experiencing a migration failure on a fresh Postgres DB with both postgres.js and node-postgres. It's complaining that an enum I have defined in my schema (which should have created already as it's in the generated migration) does not exist. ``` āŒ› Running Migrations āŒ Migration Failed...

Using Vercel Postgres and developing locally

To confirm, if I want to use Vercel Postgres in production and a local Postgres DB for development, is the best way to just conditionally import drizzle (and other platform specific stuff like sql) from drizzle-orm/vercel-postgres or drizzle-orm/node-postgres based on NODE_ENV? I see the sample Next.js project has been updated for Vercel Postgres: https://github.com/vercel/examples/blob/main/storage/postgres-drizzle/lib/drizzle.ts...

Custom Type interpreted as String

Hello everyone, I am having some issues with getting Drizzle to work with PostGIS, I am trying to have support for PostGIS's Point geometry. This is what I have setup ```typescript export type Point = { longitude: number;...

Can I use queryBuilder for inserts?

My scenario is that I want to read some rows from a database (prod), and generate a SQL file that we'd use to populate a local DB. I wanted to use queryBuilder (https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/README.md#query-builder) since I wouldn't need to connect to a DB to generate the SQL queries, but seems like queryBuilder only supports select() at the moment. Do I need to connect to a local DB if I want to generate insert() queries?

I ran introspect:pg to initialize my schema, then created a new migration. How should I deploy this?

The remote database, right now, doesn't have the drizzle.__drizzle_migrations table. It'd be nice to have a way to know that the old migrations - the ones that were generated by introspect:pg and just reflect the existing state of the database - won't run. Is this the right way to look at it? Thanks!

Transaction rollback

Hello guys. Kind of dumb question but should I cover body of transaction in try/catch and call rollback explicitly? Here is an example. What will happen some query throws an error in transaction callback? ```sessionId = await db.transaction(async (tx) => { const [{insertedSessionId}] = await tx .insert(session)...

error creating relationship

I'm having trouble creating a relationship in MySQL using drizzle-orm, I'm running npx drizzle-kit push:mysql but the I'm trying running the code inside my MySQL database but I'm getting this error Referencing column 'user_id' and referenced column 'id' in foreign key constraint 'anime_user_id_users_id_fk' are incompatible. here is the schema and the generated SQL migration code. ```javascript export const users = mysqlTable( "users",...

define default value for array

I work with a PostgreSQL database. Here is my Schema: export const user = pgTable( 'auth_user',...

TS query types dont match + no return types

I'm trying to query data from my db after importing the Item table from my schema. const data = await db.select().from(Item) As you can see in the screenshot and the error message below typescript seems to have trouble with that. Item table definition is being imported from another typescript project within the repo which might have to do with it? ...

Can't generate migrations because of top level await

This only recently started happening.Here is my drizzle.config.json :
```{ "out": "./migrations", "schema": "./src/*/.sql.ts" }...

Error types with custom schema

Hi, I'm trying to do a general function to paginate my querys, but I'm having some problems with the types. I'm trying to use the types of the library, but I'm not sure if I'm doing it right. All my tables have the same columns, so I created a function to create the base table, and I'm trying to use it to create the pagination function, and definitly i'm doing it wrong but I'm not shure how to do it, could you point me in the right direction? to know if it's possible to do it. ...

Trying to write next-auth adapter

blahblahblahrober AKA @Dan Kochetov helped me get most of the way to having a next-auth adapter done but, in the couple weeks I waited for a review, I came back and now the SQLite migration is betraying me. See video. Starting from a clean slate, it's saying nothing to migrate and, when I run tests against my db.sqlite, I get back errors for no tables, kiddo. Pretty confused; seems like I'm not pushing any schema somehow? Pull request if you want to look at code: https://github.com/nextauthjs/next-auth/pull/7165...