Drizzle Team

DT

Drizzle Team

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

Join

any way to automatically cast numeric types on retrieval?

I have a numeric field in a video table: ``` export const VideoTable = pgTable('videos', { id: uuid('id').primaryKey().defaultRandom(), height: integer('height'),...

Query in drizzle doesn't work

Error:
DrizzleError: No fields selected for table "usersToGroups" ("users_groups")
DrizzleError: No fields selected for table "usersToGroups" ("users_groups")
...
No description

Cannot read properties of undefined (reading 'referencedTable')

Seemingly getting this error out of nowhere. I believe it's related to the relations I defined, but can't quite figure out what is causing it specifically.

Relational query builder in mysql?

I cant find anything about how to implement this. Am I blind or is this impossible?

TransactionRollbackError

Need some help understanding TransactionRollbackError... Is this error saying the tx.rollback() function itself threw an error and that the rollback was unsuccessful, or just that the tx.rollback() function was called?...

PostgresError: null value in column "id" of relation "pairs" violates not-null constraint

Hello, I am fairly new to Drizzle and working with databases, so I am running into a problem that I am unsure how to solve and hope that you can help me with it. I use Directus CMS to create all of my tables. Then, I wrote schema.ts (using introspect and making a couple of manual changes). So, one of my tables looks like this:...

OnConflictDoNothing with mysql

Hi everyone, I want to use the on conflict do nothing method described here: https://orm.drizzle.team/docs/insert#onconflict-and-upsert-insert-or-update. But it seems to be that only onConflictDoUpdate is available. Is this database specific or Am I doing something wrong here? this is my query: ...

drizzle-kit introspect reorder tables

Here is the case: - I have a remote database. I made a backup and restore it locally - I ran: drizzle-kit introspect:pg --config=./database/drizzle/drizzle.config.ts - With different connections in the config: first for the remote DB and second for the local DB, I got different orders of tables in the generated schema...

Migration custom logger

Hey there, I'm want to run migration as part of my CI/CD, and would have liked the output of the migrate function to be passed to my custom logger function. is it something that is supported/planned? if not - i'd suggest adding two logging options infoLogger and errorLogger both of type (msg: string) => void thx...

why do snapshots not have the same name as the migrations?

Hey, loving dirzzle so far. Hit a snag recently. Me and my friend are collaborating on a project. We ended up in a merge conflict. Here is what happened: 1. We both created our separate branches from main....
No description

Help with improving database query

Hello, I am seeking advice on how to improve a database query I am currently working with. My objective is to get the data of a prompt using its ID, and this data includes the names of the tags associated with it.The currently way I am doing this works, but feels hacking so wondering if theres a more efficient way to achieve this, possibly through restructuring the database or altering the query itself. Below are the definitions for my "prompts" and "tags" tables from supabase DB: ```sql...

Typescript types for relational queries with neon db

Hey, I am having an issue with typescript types for relational queries with drizzle and neon db. Details: https://github.com/drizzle-team/drizzle-orm/issues/1204. Can anyone help me please?

Migrating in JS & JSON (no filesytem)

👋 we're big fans (and sponsors) of Drizzle at Val Town. We use it internally and love it. We just shipped an integration with Turso to give every Val Town user a SQLIte database, and I'm happy to report that I got Drizzle working in that environment! Integration: https://www.val.town/v/std.turso...

onDuplicateKeyUpdate

i'm having problems using onDuplicateKeyUpdate, doing it like ```js ...

Unable to generate uuid as primary key

Hey everyone! I've searched through the help posts with similar titles but I could not get the answer I wanted. I have a prisma current setup, and trying to switch over, but my uuid is generated as my postgres primary key but I keep getting the following error:
"null value in column \"id\" of relation \"User\" violates not-null constraint"
"null value in column \"id\" of relation \"User\" violates not-null constraint"
...

[Has Solution] Drizzle Studio says it's running on the server http://0.0.0.0

Idk what might be the issue. But when I run pnpm drizzle-kit studio. I am receiving the message: Drizzle Studio is up and running on http://0.0.0.0:4983 If I try to hit that route, nothing's on there. But if I instead change the URL to http://127.0.0.1:4983. It works....

Error using relational queries but not with core queries

when i do
const invitesData = await db.select().from(invites).innerJoin(members, eq(invites.inviterId, members.id)).where(eq(invites.invitedId, user.id));
const invitesData = await db.select().from(invites).innerJoin(members, eq(invites.inviterId, members.id)).where(eq(invites.invitedId, user.id));
everything works as intended, but when I do...

Is it good to use UUID as primary key ?

Hi, i want to define manually an id for my entry to be able to create at tame time a folder with same id. So using uuid can be a problem ? or maybe i have to get a normal id used for everything, and a uuid used to identify my entry in folders (for images) and for client supports ?...

What exactly i am doing wrong.. Prepared Query

```json [{ "error": { "json": { "message": "prepared statement "preparedConfig" already exists",...