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 do I configure SSL mode without using the connectionString parameter

In drizzle.config.ts I tried pushing to my database but it won't work since it requires a SSL/TLS connection. That would normally be solved using the connectionString, but I got the other parameters and I can't find a way around this. ...

notNull() is still letting field be optional

I am performing the following for SQLite: ``` export const products = sqliteTable("products", { id: integer("id").primaryKey({ autoIncrement: false }).notNull(),...

Explanation on execute() vs all() vs get() vs run()

I am using prepare() to make prepared statements for Turso (so SQLite), and the docs use prepare.all() for SQLite instead of prepare.execute() as is used for PostgreSQL and MySQL, why is that? Same goes for prepare.get() for SQLite instead of prepare.execute() When do I know when to run those different queries for SQLite?...

A very weird problem with Drizzle I'm having.

Forgive me if what you read here is hard to grasp, because I truly can't figure out what the issue is. I'm a senior at university and the project I'm working on involves using drizzle. Whenever I try to run pnpm run migrations:apply (it's in a config file that has the scripts for drizzle in it), I keep getting this error. This was after I changed my execution policy (using windows) and I don't know what's causing this error. This is my first time using Drizzle, so any help would be appreciated...
No description

Issue Pushing Schema to Turso

Hi All, I made a schema.ts with sqliteTable statements, and I created a drizzle.config.ts as follows: ``` import { Config } from "drizzle-kit";...

Delete operation in transaction sometimes not deleting row in database

Hi, I'm calling a delete operation in a transaction that deletes an organization row in a Supabase Postgres database: ```ts let data: unknown[] = []; await db.transaction(async (tx) => {...

How do I extract a shared "Schema" that is used across several tables?

I want to have a construct like this: ``` export const auditAware: ????? = { createdAt: date('created_at').notNull(),...

Getting syntax error when using the sql operator (pg)

Trying to execute this line of code:
await db.execute(sql`SET db.tenant_id = ${tenantId};`);
await db.execute(sql`SET db.tenant_id = ${tenantId};`);
the query that is produced by drizzle:...

SQLite query returns an incorrect row count in extras

The query below doesn't seem to return the correct count for the number of Posts under a Category. It just counts the whole Posts table instead for some reason. ``` db.query.categories.findMany({ offset, limit: perPage,...

update where multiple conditions

Trying to do something like a: UPDATE table SET values WHERE condition1 AND condition2 other ORMs will all you to pass in an object for conditions and they'll handle it under the hood, does Drizzle have something like this or do I need to do something like: ...

Many-to-many relation "where" only allows selection of pk fields

(Please see screenshot) How would I filter on categories with a specific field? autocomplete only shows the fields in the junction table Thanks!...
No description

one to many query

In Drizzle you can make a one to many query like this: ```ts const result = await db.query.users.findMany({ with: { posts: true ...

Introspecting sqlite database invalid syntax

When introspecting an sqlite database, inside the schema.ts file I'm seeing lines like icon: numeric("icon").default(dashboard).notNull(), where as you can see "dashboard" is a variable (that is undefined in the schema.ts file) and not a string. I saw this related issue: https://github.com/drizzle-team/drizzle-kit-mirror/issues/116...

Drizzle kit schema migration with mysql ; Rerunning the entire schema

I use mysql2 as my database and when i run my migrate script "migrate": "drizzle-kit push:mysql --config drizzle.config.ts" this works fine but when i rerun my migrate script i get this error ```Error: Duplicate key name 'company_id' at PromiseConnection.query (/home/anasmohammed361/vs/fund-master/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:35481:26) at Command.<anonymous> (/home/anasmohammed361/vs/fund-master/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:53292:33) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {...

UpdatedAt column - Postgres

What's the best practice way to achieve a standard "updatedAt" column with the pg wrapper? I've seen mysql has timestamp('updated_at').defaultNow().onUpdateNow().notNull() However onUpdateNow() doesn't appear to be there for pg....

sql template string always returns string value

addDate: sql<number>cast (UNIX_TIMESTAMP(${schema.domain.addDate}) as signed), Hi,I have this in a select query but it always returns a string value "1695371020" even though it should be a number. Is there a way to get around it? Im using planetscale....

Mysql Syntax error executing query

Hi i got this issue: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(select coalesce(json_arrayagg(json_array(stores_categories.id_store, `store' at line 1 when i try to run this query: ```js...
No description

Many to many relationship using Turso

Hello I'm new to sql in general and I just followed and copy some codes through the documentation of turso and drizzle. I'm trying to make a many-to-many relation between drinks and ingredients. I want to know this is the correct way to do it?
No description

why does it work by sorting by false but not by true?

i am certain i have one of each and it works when on false but i dont get anything back when its on true even though i have 2 rows in the table with it true ```ts const results = await db.query.workouts.findMany({ orderBy: [desc(weights.id)],...