Drizzle Team

DT

Drizzle Team

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

Join

what do we need to pass in --ssl to enforce SSL?

I have a Supabase database where SSL has been enforce. But Drizzle fails to connect to DB giving local SSL certificate error. It works fine once I disable enforcement on Supabase side. I see there is a --ssl parameter in command line, but it does not do anything/I am missing something. Can anybody please help here?

Transforming SELECT from case to camelCase via sql with execute

I am getting some values for example
comments.created_at,
comments.created_at,
I wish to transform this with the AS keyword:...

How drizzle handle nulls and undefineds ?

I'm running this query, but some values in where clause are undefined, how do i make it optional ? Error: UNDEFINED_VALUE: Undefined values are not allowed query:...

Relational queries result types are not working

Hi, When i call findMany or findFirst with no args, the result type is ``` const trips: {...

defaultRandom() on uuid results in an error

id: uuid('id').unique().primaryKey().notNull().defaultRandom(),
id: uuid('id').unique().primaryKey().notNull().defaultRandom(),
upon insert, this results in the error: NeonDbError: db error: ERROR: invalid input syntax for type uuid: "ia4afwolcuk4rks"...

Handling self referencing foreign keys

I have the following code but am getting an error that says 'people' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.ts(7022) How should I handle a self referencing foreign key like in my example below?...

WITH RECURSIVE

Is there a function WITH RECURSIVE yet?

sqlite encode

I'm trying to encode some data in the schema. I thought I could use the sql command, but I think that's only for doing default values Like for this table:...

convert from prisma

how can this relation and model with drizzle ?
No description

Running local database with edge runtime on NextJS

Hi, I've been trying to run drizzle on /pages/api route (edge runtime) in NextJS but I can't get it to work locally. It feels like I've tried every combination of drivers so far but they either refuse to connect (neon and vercel/postgres for example does not like my connection string), complain about node modules or just doesn't seem to be able to fetch anything (seemingly connects but awaited queries do no not return). I have a postgres database that works with the node-postgres driver for trpc endpoints. Any help is appreciated...
No description

help with a generic mysql2 connection

gday folks, im trying to create what is essentially a generic mysql2 connection that is compatible with planetscale but also compatible with a local msyql2 server running in docker, for instance...my production database is planetscale hosted and any sort of dev or testing i want to do locally. My connection at the moment is literally just drizzle(connection, { mode: DB_MODE, schema }) however due to the sheer amount of options within the configuration im concerned im missing something crucial for the continued integration with planetscale with such a minimal config. granted the port, user, password, schema, etc are all in the uri, but is there anything else i should be considering?...

Select as db column names instead of js property names

Is there a helper to make select queries that return db column names, i.e. snake-cased instead of the camelCased schema names? I figure I can implement pretty easily, just wanted to know if there's already something provided by drizzle?

Unable to make migrations

Hey guys. I don't want to push it too hard, but am I the only one who stuck with this issue? I can not downgrade drizzle kit (it throws error that package is outdated), and I basically can not apply any changes to database - it basically blocked any further development. Do you know any workaround for that, or at least the reason why It's happening? I'm referring to https://github.com/drizzle-team/drizzle-orm/issues/1119...

where(gt) with timestamp returns wrong result

Might be a SQL inherent thing, but I'm a bit puzzled as to why this happens: Edit: for terseness I left out some code. I think the issue is clear ```ts...

node-postgres uses crypto under the hood ?

Hello everyone, so I'm migrating from Prisma to Drizzle so I can use the NextJS's edge runtime I'm trying to make a query inside my edge middleware and I get the following error: The edge runtime does not support Node.js 'crypto' module. ...

SyntaxError: Unexpected identifier 'SCHEMA'

I'm trying to execute "drizzle-kit generate:pg" and I'm receiving error: CREATE SCHEMA "boards"; ^^^^^^ SyntaxError: Unexpected identifier 'SCHEMA'...
No description

How can I create a virtual table with sqlite?

I am using turso & sqlite. I have enabled the FTS5 extension so I can perform full text search. I want to define a virtual table in my schema so I can query it using drizzle. If I define it as a regular sqliteTable, running db:push from drizzle kit will create the table and break the virtual table. What's the best way to proceed?

Is it possible to identify modifications in a pg db and extract/pull them as a new migration file?

Here is the situation I am referring to: 1. When I run drizzle-kit introspect:pg for the first time, it generates 0000 migration. 2. A new table called my_new_table is created using native pg (without ORM). 3. (I wish to) When I run drizzle-kit introspect:pg for the second time, it generates a 0001 migration with my_new_table included....

PostgreSQL "type serial does not exist"

I'm getting an error when using serial and primary key. Just trying out postgres for the first time so its very possible I messed something up, the serial type works perfect on non primary key fields ```ts export const users = pgTable( "users",...

how to express the "children" relation in parent/child?

I have a table with columns id and parent_id - and I want to setup a parent/child relationship. Using the relations, one, and many I've got this but not sure if it's correct. If I'm able to express my "parent" relationship, shouldn't I also express my "children" relationship as well?...
No description