Drizzle Team

DT

Drizzle Team

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

Join

withPagination type inference

Looking for help as to why my types on this withPagination function are not getting inferred correctly. Data does on the PaginatedResult does not get full inferred at the top level. pagination.ts ```typescript import type { PgSelect } from 'drizzle-orm/pg-core'...

How can I reset migrations timestamp

I am using drizzle in one of my projects and somehow the timestamp of migrations were wrong. Trying to fix it, I edited, by hand, the timestamp value in meta/_journal.json, increasing the timestamp value present in when key. The value I put there is far in the future, and because of that, every new migration that I create is not running due to that inconsistency. So my question is: Can I fix it? How? My meta/_journal.json looks like this: ```json...

drizzle-kit generate with dynamic Schema

Hello, I work in a context where each dev has its own schema in the DB. When generating migrations with drizzle-kit generate, the migration files contain the hardcoded schema value ex: CREATE TABLE "mySchema1"."myTable" ...

Filter based querying

So in my case I have a doctor to fetch. Now I don't know how to do a filter based on these doctors. So should I make a subquery which get all doctor data needed generally. And than on that query based on filter so if filter by price or rating do the actually query. It would be really nice if someone show a code example

Using drizzle with dynamic drivers

Hi! How can i use drizzle with dynamic drivers ? I am using it in my frontend, but the db is mainly handles by backend using sqlalchemy. So for frontend, i just introspect db and pull the schema and relations from it. Worked fine for introspect since it asks for stuff and i can pull in from env, but when i want to make db i am confused on how to do. Because there are different packages and different formats

Automatically lowercase fields

I use sqlite I want to implement a function that automatically changes the address field to lowercase when my address field is updated. Is this correct?...
No description

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

No idea what am I doing wrong, my query looks like: ```db.query.ProductTable.findFirst({ where: eq(ProductTable.slug, productSlug), with: {...

When using $dynamic(), are the where conditions merged or overwritten?

Title. Just wondering. The docs weren't super clear about that part in my opinion.

separating relations to different file results in typescript issues

I have updated my config to this and just move the relations to relations.ts
schema: ["./server/db/schema.ts", "./server/db/relations.ts"],
schema: ["./server/db/schema.ts", "./server/db/relations.ts"],
...

Hey, I have an existing table in my neon database but when i run the command "npx drizzle-kit push"

Im getting this error '@Neondatabase/serverless' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket [✓] Pulling schema from database... error: cannot drop sequence "mockInterview_id_seq" because other objects depend on it at /Users/raunak07/Documents/Code/interview/node_modules/drizzle-kit/bin.cjs:96850:23...
No description

Issues deploying with Dockerfile

I'm using SvelteKit, and I run my migrations on app start in hooks.server.ts After building with Dockerfile, I get these runtime errors nonstop: ``` Node.js v18.20.4...

drizzle-kit push -> dialog is undefined even if i have it in the config

This is the error: ```yarn run db:push yarn run v1.22.21 $ drizzle-kit push --verbose...

geometry not available on 'drizzle-orm/pg-core'

The documentation says that the geometry from PostGIS can be imported from the pg-core library, but I am unable to.

Drizzle Kit Studio inaccessible in cloud development environments

Description: I'm encountering an issue with Drizzle Kit Studio when developing in cloud-based environments. The problem persists across multiple platforms, including Gitpod, GitHub Codespaces, and Project IDX. Environment: Next.js version: 14.2.5...
No description

Using drizzle-kit:generate with path aliases

Hey guys 👋 I'm currently trying to migrate my codebase to use drizzle, however I'm facing an issue related to how drizzle-kit handles TS paths. I am using a NX monorepo, with path aliases....

Multi-step migration in SQLite with 'MODIFY'

I'm trying to create a multi-step migration in SQLite. First an alter to add the field (nullable), then a CONCAT to amend the field, lastly alter to make it non-nullable. I'm getting The supplied SQL string contains more than one statement. Not sure if I'm thinking about this the wrong way... Trying to split up the migrations into three step, but it seems like the last step (ALTER TABLE table MODIFY) to apply the not null constraint is not permitted in sqlite... I'm not sure how to handle this. Any ideas?...

Extending Relations

I have a nextjs project with supabase as backend database. I introspected the auth table since I created a several tables that extend the auth.users table. The generated file has many relations already setup. When I try to add my own relations in the schema file, it seems to remove the types and the queries are no longer typed, i.e the response only contains the auth.users columns and not the related tables even when using the with keyword. My thoery is creating two separate relations on the same table is messing things up. So my question is that is there a way to extend the relation in the generated file since I would prefer not to touch this file?...

SQLite 'WHERE table.relationship (one to many) > 0'

Hi! I'm trying to figure out how to query for rows that have a relationship at least defined once. ```ts const allVideos = await db.query.videos.findMany({ where: // Not all videos have timestamps (one-to-many). Exclude those somehow with: {...

Querying and typing a many to many relationship?

So I'm enjoying using drizzle, but querying a many to many relationship seems a bit verbose, which makes me think I'm doing it wrong. It's also making using drizzle-zod a bit confusing: So I've set up my tables, user and profile ```...

I'm getting a Postgres Error when running my drizzle query but not when running the generated sql

I have a drizzle query. `` const staffDateExpression = sql<Date>date_trunc(${timeFrame}, ${CalendarEvent.startTimeUTC})`; // 1. Calculate staffing costs const staffingCosts = await ctx.db...
Next