Drizzle Team

DT

Drizzle Team

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

Join

Syntax Error and missing fields when pulling schema.

I already have a project in which I used prisma. Now I want to switch to drizzle, I ran drizzle-kit introspect:pg and it generated a schema.ts file as expected but the user model is missing role field and schema file has Syntax Error

Support for streaming rows?

Is there planned support or at least would it be considered to support streaming large result sets in Drizzle? Both postgres and mysql drivers support streaming rows and expose it as an async iterator. It would be great if this was supported natively in Drizzle...

Planetscale Serverless for Relational queries

Currently it is only supported to use mysql2 for using the Relational queries feature with Planetscale, with that the advantage of using the serverless driver with planetscale vanishes. Would it be possible to implement the planetscale serverless driver instead of mysql2? Thanks for any answer 🙂 Edit: Yes you can use it with PlanetScale driverless just like normel...

Is it safe to use: `sslmode=require`?

I keep getting: error: connection is insecure (try using sslmode=require`) - Can I safely use in localhost & production?

Error with drizzle-kit generate:pg

Transforming const to the configured target environment ("es5") is not supported yet

Recommended approach for generated columns

since generated columns aren't supported yet in Drizzle, i wanted to know what's the recommended approach to declaring one (in PG)

Which driver should I use for neon?

Currently I use neon and all seems to work fine, also db:push with the driver set as pg. The only issue I have is with studio which throws: ```sh Cannot find package 'pg' imported from ...node_modules/drizzle-orm/node-postgres/index.mjs...

Top Level await issue with latest [email protected], mysql2, planetscale

We are getting this error when following the release notes recommended setup for pscale/mysql: ``` [ERROR] Top-level await is not available in the configured target environment ("node14") remix-app:dev: remix-app:dev: ../../packages/db/index.ts:18:19:...

Nullable relational query?

In the following, shouldn't res.jobSeekerProfile possibly be null? Basically what I want is to get the user - Include their jobSeekerProfile (if they have one). Currently, it seems to assume that jobSeekerProfile always exists for the user ```ts let test = db.query.users.findFirst({ where: (users, { eq }) => eq(users.id, '1'), with: {...

customType causing type error when performing operation on table

I have a simple customType to use the citext extension in Postgres. ```ts import { customType } from "drizzle-orm/pg-core"; ...

How to specify type using sql template

I'm using this piece of code ``ts const ids = [ 3445, 3446, 999 ]; const values = sql.join( ids.map( v => sql(${v}) ), sql,` );...

Why {unique:true} doesn't throw?

If I add 3 users with the same email address, it adds them without any issue. How can I make sure the email is unique? I also tried with: email: varchar('email', { length: 256, unique: true, notNull: true }).primaryKey() ...

Get the latest message from each user in a table

Say my messages table looks something like this: ``` content|sender_id|recipient_id|sent_at_timestamp hello|1|2|yyyy-mm-dd # message 1...

Infinite loading of queries

Hey! I am trying to use Drizzle with Neon Postgres. I made the migrations, ran them and the tables are there. Now whenever I select or insert data, the request just hangs and does not proceed. I am using serverless neon package since I will be running in Vercel Edge Functions. Here is the code: ``` import {drizzle} from "drizzle-orm/neon-serverless"; import {Pool} from '@neondatabase/serverless';...

Share drizzle-zod schemas with the frontend

I'm wondering how I should use drizzle-zod generated schemas without leaking the actual implementation of my tables to the frontend? I'm assuming by exporting drizzle-zod schema's and letting the frontend consume them, I'm actually bundling the definitions inside of my FE as well. Is there a way to avoid this? Or frankly, should I not care?...

Suggestion: Add warning when adding breaking changes.

For example: adding a non null field without a default value

There is not enough information to infer relation. What am I doing wrong?

I have such a setup yet I'm getting There is not enough information to infer relation "users.organizations". What am I missing? (below are all my relations) It's a many-to-many relationship. I also registered all that stuff into the schema (below) ```ts...

Baseline for introspected schema

I've used "drizzle-kit introspect" to get my initial schema and migration files. How do I now mark that initial migration file as applied (create the _drizzle_migrations table)?

Identifier is too long (should not exceed 63 characters)

Hello guys. I've got too long constraint id generated by drizzle kit in migration files. Is it safe to apply such migration? Maybe there is a way how I can set custom constraint id for some tables? Here is my schema ```TYPESCRIPT export const customerVehicleClaims = pgTable('customer_vehicle_claims', { claimsid: text('claimsid').primaryKey().notNull(), customervehicleid: integer('customervehicleid')...

How can I declare a relationship with a SELECT statement?

I have 2 tables, iot_device and iot_device_status, where the status table saves all current and historical statuses of each device. I like to join the tables together as so: ``` SELECT i.id, i.name, data.lost, data.created_at FROM iot_device i INNER JOIN LATERAL ( SELECT * FROM iot_device_status s...