Drizzle Team

DT

Drizzle Team

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

Join

sqlite insert results in error: "SQLite error: no such table: main.__old_push_items"

2 of my 3 table insert work fine, but my auctions table inserts do not work for some reason. When I try to insert data into my sqlite db on Turso I get the following error:
LibsqlError: SQLITE_UNKNOWN: SQLite error: no such table: main.__old_push_items
LibsqlError: SQLITE_UNKNOWN: SQLite error: no such table: main.__old_push_items
...

A way to use the update function with existing value in row?

How do I do the following SQL UPDATE counts SET count = count + 1 WHERE id = 1 but with drizzle orm, such as ...

group by inside relations ?

i want use groupBy inside a relations ``` const tire = await ctx.db.query.tire.findFirst({ where: (tire, { eq }) => eq(tire.id, Number(input.id)),...

Insert or Update: Error undefined is not an object (evaluating 'col.name')

Hi, I'm trying to implement Insert or Update ```ts export async function insertOrUpdateUser(user: UserInsert) { const db = await getDatabase();...

mysql2 many-to-many

Is there an example of a mysql many-to-many relationship? I haven't been able to find one and I'm getting a foreign key constraint db error similar to this post https://planetscale.com/blog/working-with-related-data-using-drizzle-and-planetscale. I've created a join table with foreign keys and relations in line with the example here https://orm.drizzle.team/docs/rqb#many-to-many. Many thanks!...

Dynamic Drizzle Relational Queries

Hi everybody, hope all is well. I was wondering if there is a way to build dynamic queries when using drizzle (relational) queries. I read the section on dynamic query building but it doesn't cover relational queries. I'm building a rest API and I want users to be able to pass filters via query params....

migrate isn't applying the latest migration sql file

Hi, I made some changes to one of our schemas and I ran drizzle-kit generate to create the new migration sql file. However, when I ran the migrate script, it doesn't seem to be applying the migration. Any ideas what could be wrong? Our migrate file looks like this ``` async function run() {...
No description

ER_WRONG_AUTO_KEY - Drizzle Kit not detecting primary keys

Having trouble with the latest release of drizzle. Seems like drizzle is not detecting primary keys so every time I make a change to the schema and run drizzle-kit push:mysql with planetscale, it says the given error no matter what I change. I’m using the latest version of drizzle-kit and drizzle-orm. It’s fixed by downgrading to the previous major release. This is the thread most similar to the issue https://github.com/drizzle-team/drizzle-orm/issues/1428

Update number column with it's current value and new number

I need to convert this RAW sql query into a query in drizzle, but I can't find a way. Anyone done something similar?
UPDATE products
SET quantity = quantity + 15
WHERE id = <my-id>;
UPDATE products
SET quantity = quantity + 15
WHERE id = <my-id>;
...

How to use inner join with rqb?

Hello there! Having the following schema ```ts...

Using 'where' inside 'with'

Hello! I'm using schema like this: ` export const user = pgTable('user', { id: serial('id').primaryKey(), username: text('username').notNull(),...

json column type mismatch when using db.query

Hey all i have a schema with a json column, when I import the table records the type is inferred as 'unknown'. Any ideas on how to get this working, or do I have to infer the types manually? Thank you!...
No description

I swear this infer was working... am I crazy?

``` export type User = typeof user.$inferSelect; export const user = pgTable('user', { id: bigint('id', { mode: 'bigint' }).primaryKey(),...

optional join

it would be nice if we could do something similar to the where function, where if we return undefined, nothing happens, to do optional joins.

How to create a transaction outside of callback function?

Specifically for postgres Example Usage: ``` const tx = db.transaction()...

Access relation

if i use this example from docs ...should i be able to do both user.profileInfo and profileInfo.user? I want to query with WITH but somehow it works only one way.(i get type never)
No description

DB type error

I have looked at other help questions for this, but they don't really help me understanding the issues I have. I can do something like: ```javascript...

Generate drizzle migrations and push with drizzle kit with github actions for preview environments

Hello, so I am trying to deploy a preview environment with vercel and neon. Using this tutorial: https://www.youtube.com/watch?v=jjRasfbeYHk (related repo: https://github.com/neondatabase/preview-branches-with-vercel/blob/main/.github/workflows/deploy-preview.yml) . I have managed to make my workflow execute when I create a pull request, however I am running into issues when attempting to migrate and push those migrations to a generated neon branch. The repo above is using prisma, which is why I am having trouble using drizzle for this workflow instead. ...
No description

VSCode - how force auto-imports from 'drizzle-orm/pg-core' instead of 'drizzle-orm/mysql-core'

Hey, I'm using drizzle ORM with Visual Studio Code and it always auto-completes the 'drizzle-orm/mysql-core' package even when I'm already importing other stuff from 'drizzle-orm/pg-core' in the same file. It's not a big deal, you can just scroll to 'drizzle-orm/pg-core' but it's annoying. I've so far tried, but with no luck: - Setting autoImportFileExcludePatterns: ```...