Drizzle Team

DT

Drizzle Team

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

Join

onDelete cascade, Error: VT10001: foreign key constraints are not allowed

Trying to add onDelete cascade and db push produces this error: foreign key constraints are not allowed ```...

How to handle adding new columns to schema?

I have a schema, but I've decided I need to add a new column. I change the schema.ts file, push, and get the error ``` LibsqlError: SQLITE_UNKNOWN: SQLite error: table work_experience has 7 columns but 6 values were supplied...

drizzle push and primary key order

right now the primary key order isn't respected at least on MySQL work around is i just fix it manually using alter table statements but all my coworkers have to do this also - ideally this can be respected...

Drizzle can't find local sqlite file

I'm trying to play around with sqlite but I can't seem to connect my config and local sqlite db file. Config: ```ts import type { Config } from 'drizzle-kit';...

How to debug Drizzle queries

I'm executing an insert on a table, I'm gettin no errors, and yet the data is not being saved to the database. Just curious how I am supposed to debug stuff like this since I have no idea why it isn't working....

TypeError: Cannot read properties of undefined (reading 'referencedTable')

Here is the relational query that I'm trying to execute (Turso SQLite): ```javascript const result = db.query.product .findMany({ where: (product) => inArray(product.id, keys),...

Querying with two consecutive WITH causes error "the table is not part of the query"

I created my query by stages. I create a part, check it's result via await and .all() then I turn it to CTE ($with) and use in from() of the next stage. The first part (screenshot 1) 1. Worked well via direct await 2. Worked well when turned into $with and used in .from() of next stage...
No description

[Fixed] - Next.js remaining connection slots are reserved for non-replication superuser connections

I am frequently getting the above error. Database: Supabase Github: https://github.com/ShaikRehan123/questionPaperCreation ...
Solution:
Did you try to restart your Supabase instance? It happened to me sometime after a deploy on fly.io (with Remix, so we can agree it's not related to a specific platform/framework)

[drizzle-zod] How to make all fields of a schema derived from a table required ?

I just tried the plugin and I'm happy to move from manually creating zod schemas. However, I came into a use case where a schema must have all nullable fields in the table required. Assume we have these in users table: ```typescript...

Is there a way to declare a custom SQL index?

I'm trying to create an index on the lowercase value of a column using Postgres. I tried
unique().on(sql`lower(${table.username}::text)`)
unique().on(sql`lower(${table.username}::text)`)
but "on" only accepts columns...

sqlite code first with in-memory db

Hey, I thought it'd be rather easy to create a schema from scratch without running a "migration" (from nothing to v1 is a migration?), but apparently I was wrong. I'm using bun:sqlite and would prefer to not create some migration files or whatever. Shouldn't db.run(table.getSql()) work? Is there even an option to bootstrap a schema without creating additional files?...

Drizzle-Kit: incorrect schema.ts being used

I have some schema files in a subfolder. I have referenced the path in the drizzle.config.ts, but instead drizzle just creates a schema file in the drizzle directory next to migration files. What gives?...

Group by Multiple columns with drizzle

I have a schema that looks rougly like this:
date | location | name | quantity
date | location | name | quantity
I want to groupBy multiple columns(date,location), but I'm not sure if there is a drizzle-way to do it, or should I do a raw query? ...

[Fixed] is not assignable to parameter type Record<string, PgColumnBuilder>

Hi, Trying to install Drizzle, using the basic example from the docs. Getting the following error:
Argument type {phone: PgVarcharBuilder<{name: "phone", dataType: "string", columnType: "PgVarchar", data: [string, ...string[]][number], driverParam: string, enumValues: [string, ...string[]]}>, fullName: PgTextBuilder<{name: "full_name", dataType: "string", columnType: "PgText", data: [string, ...string[]][number], enumValues: [string, ...string[]], driverParam: string}>, id: PgSerialBuilder & {_: {notNull: true}}} is not assignable to parameter type Record<string, PgColumnBuilder>
Argument type {phone: PgVarcharBuilder<{name: "phone", dataType: "string", columnType: "PgVarchar", data: [string, ...string[]][number], driverParam: string, enumValues: [string, ...string[]]}>, fullName: PgTextBuilder<{name: "full_name", dataType: "string", columnType: "PgText", data: [string, ...string[]][number], enumValues: [string, ...string[]], driverParam: string}>, id: PgSerialBuilder & {_: {notNull: true}}} is not assignable to parameter type Record<string, PgColumnBuilder>
...
No description

What is the Drizzle convention for storing the `db` object?

In the "Quick Start" guide, it showcases connecting to the database at the root of a module. However, in real code, this would likely be in a file called "db.ts", and it would not be at the root of the module, since the connection string would not yet be available. This is my naΓ―ve attempt to show what a more real-life code would look like: ```ts export let db: PostgresJsDatabase;...

Default value for Array creates an incorrect SQL migration

I'm currently adding a new field roles to my PG table, users, such as: ```typescript export const users = pgTable( 'users', {...

Bug: drizzle-kit generate:pg didn't see the changes in the schema

On my uniqueIndex i added a where clause to not check the soft delete records. When running generate, the drizzle-kit didn't generate any migration since it thinks i haven't modified the schema.
No description

update multiple fields

Hi is there a other way to update multiple fields currently i do it like this ```js const updatePollOption = (option: PollOptionsSchema) => {...