Drizzle Team

DT

Drizzle Team

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

Join

PGSql Batch/Merge Queries for Perforamnce

I currently have several queries that execute sequentially but they are somewhat independant of one another in that they dont need each others output. A psuedo code example is ```...

cannot insert into column "id"

i get this error when i try to insert more than one value into my postgres ```export const productsTable = pgTable("products", { id: integer().primaryKey().generatedAlwaysAsIdentity({ startWith: 1000 }), name: varchar({ length: 255 }).notNull(),...

Sourcemap for "..node_modules/.vinxi/client/deps/drizzle-zod.js" points to missing source files

I am trying out drizzle (and drizzle-zod) in my SolidStart project and I am getting this error/warning:
Sourcemap for ".../node_modules/.vinxi/client/deps/drizzle-zod.js" points to missing source files
Sourcemap for ".../node_modules/.vinxi/client/deps/drizzle-zod.js" points to missing source files
I am pretty unfamiliar with the ins and outs of how code gets bundled in SolidStart and source maps in general. I am wondering if you guys know if this message implies an issue with drizzle-zod or SolidStart?...

Not connecting to Drizzle Studio

I am getting this message when trying to use Drizzle Studio. "Hey 👋 Welcome to Drizzle Studio Connecting to the Drizzle Kit on localhost:4983". It just hangs. The database postgres/gis is running. Using Chrome browser....

gt and lt conditional filter behaves like gte and lte filter for timestampz column

when i filter with greater than or less than filter operator from drizzle orm, it returns results greater than or less than depending on the operator used along with the row that matches the filter value essentially behaving like greater than or equal to and less than or equal to operators. the filter value is a date, i also tried it with a string by setting the timestampz column mode to a string but still got the same result. the only solution i hv found so far is by truncating the date value a...
No description

Help me understand the createUpdateSchema

I am trying to build a form that will both be used for creating but also updating. Here is what I have so far ```js...

Why can't I insert fields that have already been defined in the table?

This is my user schema ```ts export const users = pgTable( 'users', {...
No description

Error [ERR_MODULE_NOT_FOUND]

im not sure as to why im getting this error when i run my index.ts
No description

Traversing many to many relationships with sorting and filtering based on the related table.

In my project I have the following tables: `events: { id: number name: string...

Mismatch between docs and TS typings for Neon BatchResponse?

I'm currently in the process of switching my db provider to Neon (using the HTTP driver), and so I'm switching from using .transaction() to .batch(). I understand that they don't have entirely the same behavior, and for my use cases this is fine. However, I've run into a disconnect between the docs at https://orm.drizzle.team/docs/batch-api and the Typescript typings for .batch() in the drizzle-orm/neon-http flavor of Drizzle. The docs indicate that for code of the form const batchResponse: BatchResponse = await db.batch([...]);, the type BatchResponse is essentially: ...

TypeScript Function That Generates a Schema with Dynamic Fields and Maintains Correct Return Types

I’m trying to create a TypeScript function that takes configuration parameters and generates a schema with some default fields. However, I’m struggling to get the correct return type for the function. Specifically, the autocomplete doesn’t show the fields created from the parameters. Here’s an example of what I’m trying to achieve: ``` function createSchema(tableName: string, fields: { name: string;...

Any way to work with jsonb in a sqlite db?

I have a local sqlite db that I want to sync to supabase. The supabase column is of type jsonb. This is the local table definition: ```ts export const userProfilesTable = sqliteTable('user_profiles', {...

db.query error: TS2339: Property priceRules does not exist on type {}

So when using drizzle schema's imported from a node package (we do this as we are in a mono-repository and it's easier to manage versioning this way), I get this error, which claims the property doesn't exist, even through the tooltip has the value and I've verified the package does export the schema with this value on. Any advice? db.ts...
No description

SQLite self referencing table

Hi! I'm trying to achieve self referencing category structure in my application. Found this article from wiki: https://orm.drizzle.team/docs/indexes-constraints#foreign-key ```typescript import { WithNumericId } from "@/lib/util-types"; import { relations } from "drizzle-orm";...

[BUG]: Two fails with `There is not enough information to infer relation`

https://github.com/drizzle-team/drizzle-orm/issues/4140 Below is a minimum reproduction. 1/ one-to-many doesn't work when the one() relation uses multiple fields. ...

db.select() from magic sql`` operator returns array of empty objects

I am generating a set of dates using generate_series and I can't get it to actually return the dates in drizzle. Here is the query: db.select().from(sqlgenerate_series(make_date(2024,2,1), make_date(2026,12,1), '1 month'::interval)); When I use drizzle runner in studio, it returns the proper number of results in an array of empty JSON objects. If I run SELECT * FROM generate_series(make_date(2024,2,1), make_date(2026,12,1), '1 month'::interval) in SQL console, it works just fine. ...

Dynamic Table Names

I am new to drizzle (started today) and am wondering if it is possible to have a dynamic table name. I have a database that has a new table created for each month. The schema of all these tables is the same. Is it possible to just have 1 schema definition instead of needing to have this repeated? I was able to accomplish this in the past using sqlalchemy using the blow config. Sorry if I have asked this in a confusing manner. Current Drizzle: ```typescript export const sqltData1202401 = pgTable(...

How to avoid migrations merge conflicts with multiple team members working in parallel

The current problem is, whem multiple team members work in parallel on the same project, we have to deal with a lot of merge conflicts in journal, snapshots, and migrations when merging prs. current solution that we found is rebase main into feature branch, drop all migraitions so migrations are up to date with main and then generate single migration that includes all changes made on the feature branch. It works, but maybe there is any easier approach to deal with that?

drizzle-kit push fails with neon

I connected drizzle with a neon posgres instance. The connection itself works and i can query data. But when i comes to drizzle-kit and pushing a scheme, i encounter problems. Credentials in drizzle.config.ts are correctly set (i tried both url and manually setting all credential properties)....

How to Setup Drizzle ORM with Expo SQLite in React Native?

Hello everyone, I'm trying to set up Drizzle ORM with Expo SQLite for my React Native project. I have an existing SQLite database file (data.sqlite) that I want to use with Drizzle for type safety and better query building. can anyone suggest me any repo or docs, it would be very helpful. Thank you....