Drizzle Team

DT

Drizzle Team

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

Join

How to implement interface for table?

Say I have an interface of User ``` interface User { id: string,...

onDuplicateKeyUpdate

Is this the correct way to use this method? Can't find documentation ```db .insert(schema.item) .values({...

drizzle weird error message on database operation

I am getting this weird error when doing database operation

permission denied on insert

I have a drizzle user with full permissions set but I am getting permission denied errors, I have rls enabled

How can I reference the RelationalQueryBuilder and RelationalQuery types?

These types are currently not exported from the library AFAIK. I would like to reference these types to build a generic query builder for our internal use. How can I get to them?

Dropping unique constraint cant push to db

I have this key here nftCollectionIdKey: unique("Pool_nftCollectionId_key").on( table.nftCollectionAddress ), ...

I'm getting circular dependency problems because each table relation is declared from the table file

Is there a better way to declare relations ? What I ended up doing was declaring all my relations in a separate file "relations.ts"....

How do I import a type?

This might be something I'm just totally overlooking, but I'm used to prisma where you can just import any schema you've defined as a type. For example, if I have a table posts, I'd expecect to be able to import a Post type to be used in one of my child components. Is this possible with Drizzle? Or have you all found it to be unnecessary...

When pushing migrations to Supabase, it skips saying the schema "drizzle" already exists.

When I update my schema and try to push the migration to Supabase, I get the following error. How can I move forward with pushing it as opposed to having it skip? I guess part of the issue is I don't understand how migrations really work so not sure what this error is telling me is wrong. In my database, I already have 2 entries in a table called __drizzle_migrations under the drizzle schema that was auto-created by drizzle-kit when migrating the first few times ```js...

0 tables fetched when introspecting a postgres database

I granted all permissions to a drizzle user like this
GRANT ALL PRIVILEGES ON SCHEMA public TO prisma;
GRANT ALL PRIVILEGES ON SCHEMA public TO prisma;
But when I try to introspect with this connection string...

PostgreSQL migration issue in AWS RDS with Drizzle ORM: 'no pg_hba.conf entry for host' error

I've been using drizzle for a new project over the past few weeks, and it has provided a great developer experience. Now, it's time to bring the app to production. However, I'm currently facing an issue with the migrations. The app is deployed in AWS ECS and connects to a PostgreSQL database in AWS RDS. I have provided the necessary IAM policies in the ECS task role to access the RDS instance. The connection is established but after that when I execute the migrate function, I'm encountering an error that I didn't experience while running locally. ```...

Date condition on where function

Hello everyone, so I have this schema of accounts and I want to get all the data from the current date ``` export const accounts = mysqlTable("account", { ......

ReferenceError: Cannot access 'addon' before initialization

This is one of the files in ./schema/ ```ts import { integer, primaryKey,...

DISTINCT ON syntax error with multiple columns in select

Hi! Thought I'd bring up this issue I opened here: https://github.com/drizzle-team/drizzle-orm/issues/963 Let me know if we think this is a valid issue or just a pure user error. Happy to close it if I'm doing anything wrong!...

Unchanged schema, `db:push:pg` generates faulty `ALTER` statements

Schema: ``` CREATE TABLE IF NOT EXISTS "private"."users" ( "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL,...

Get `id` of inserted row

Is this the right way to get the id of an insert? It feels incredibly cumbersome for such a common pattern, so feel like I'm doing something wrong:
const { resultId } = (await Database.insert(UsersTable).values(userInsert).returning({resultId: UsersTable.id}))[0]
const { resultId } = (await Database.insert(UsersTable).values(userInsert).returning({resultId: UsersTable.id}))[0]
...

Column primary key not working

What am I doing wrong when defining my primary key here? column: ``` const customPrimaryKey = customType<{ data: number;...

Drizzle kit SQL error

Hi all, I'm getting this weird error when I try to push my schema changes using drizzle-kit push and I have no idea where to begin to solve it: ```bash...

Migrating prisma schema to drizzle

Hey you all, I'm currently migrating my prisma schema to drizzle. I'm using sqlite and checked out how the types of prisma transfer to sqlites types. However drizzle doesn't support numeric and decimal and I wondered which datatype I would use instead. Also what is the best way to implement prisma features like cuid() Using a library and then doing string("id").default(cuid())...

How to make an unsigned bigint column in MySQL

Hiya folks, I am trying to use lucia auth with drizzle, and it requires me to make a table with unsigned bigint, however I can't seem to find that option anywhere in the documentation or google. Can someone help me with that. Thanks a ton