Drizzle Team

DT

Drizzle Team

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

Join

Drizzle-kit push not creating new column

I have a basic schema for a user, which I set up the database for using drizzle-kit push. I added a new avatar field to the users, and tried to use push to update the schema, but instead got this: LibsqlError: SQLITE_ERROR: no such column: avatar Looking at the generated SQL it's trying to copy over the new column, and doesn't try to create it. `` INSERT INTO __new_users("id", "name", "email", "avatar", "created_at") SELECT "id", "name", "email", "avatar", "created_at" FROM users`;...

posible to add a serial column in a existing table? (PGtable)

Im wondering if its posible somehow to add a serial column in a table that already exist

Suggestion for the Caching API

Hi, I was playing a bit with the upstash cache and it's very usefull for catalog tables. For example: categories, tags, countries, etc. But when it comes to filtered queries, it would be cool to cache by some column. For example: cache queries by userId in the posts table. And then invalidate by the userId. May be this is already possible and I didn't see it....

Can I set a UNIQUE constraint with a conditional?

I need to ensure uniqueness in an attribute but this attribute can be NULL. A simple .unique in my schema does not work in a sqlite database. My goal is to achieve the equivalent of CREATE UNIQUE INDEX unique_product_barcode_not_null ON products(barCode) WHERE barCode IS NOT NULL; using the Drizzle schema api....

SQL within a single migration is generated out of order

Case 1: I have two tables ```javascript export const survey = mysqlTable("survey", { id: varchar("id", { length: 64 })...

pushSchema from drizzle-kit/api is not working if pgSchema specified in the schema.ts file

Hey, I'm trying to apply migration file to a custom schema using this approach (https://orm.drizzle.team/docs/schemas). If I'll specify pgSchema in schema.ts file the pushSchema still tries to apply to the default public schema ignoring the pgSchema declaration: my schema.ts: ``` export const schema = pgSchema('custom_schema_name');...

Generic base repository abstract class

So, I’m trying to create a base repository class to extend based on my schema definitions, thing is I’m having trouble getting the types to work, here is my example ```import type { InferSelectModel, SQL } from 'drizzle-orm'; import type { AnyPgTable } from 'drizzle-orm/pg-core'; ...

LibsqlError: SERVER_ERROR: Server returned HTTP status 404

Hi guys, anyone else getting this error on running large migrations? ``` try { const response = await db.transaction(async (tx) => {...

Order By Relational Data

I'm testing out the new relations API and have a slight issue but I'm not sure if this is a limitation of the querying API or if I'm just missing something. The scenerio is that I have 2 tables with a one-to-one relationship between them on a column. For instance: ```...

TypeError: Cannot read properties of null (reading 'constructor')

Attempting to do drizzle-kit generate, getting errors which I'm struggling to debug. Confirmed with colleague on same branch of the project, working on their machine. Done fresh installs of Drizzle-orm and Drizzle-kit, both locally and globally. Versions tried: ...

can't push changes to SQLite database

Hey folks I had the following schema ```ts import { createId as cuid } from "@paralleldrive/cuid2"; import type { InferInsertModel, InferSelectModel } from "drizzle-orm"; import { relations, sql } from "drizzle-orm";...

How to use in browser environment?

Hi, I'm trying to use Drizzle ORM in browser with wa-sqlite, a SQLite WASM lib. There are no drivers for it. How can I use it? I made my db execute function, which takes an sql string and a params array which I can basically call from Drizzle query builder / sql tag. I mean the output of these:...

How to deal with conflicts in db migrations between environments

Recently, our prod and staging environments got out of sync as we had to hotfix some fixes into prod. However, this now means that we have different migrations with the same number in 2 different environments that we now need to reconcile. Sample timeline 1. Staging and prod are both at migrations 33 2. Feature work gets deployed to staging, at migration 34...

Error Handling In Drizzle

I'm very new to drizzle, but like the feel of it, and the simplicity it provides. One thing that I am wondering about is error handling. How to I tell when querys fail and get information about it? I can't seam to find much about this online. Thanks!

drizzle-seed thinks I'm not using MySQL.

Error: The drizzle-seed package currently supports only PostgreSQL, MySQL, and SQLite databases. Please ensure your database is one of these supported types
at seedFunc (/Users/user/Code/starter/node_modules/src/index.ts:393:9)
at SeedPromise.then (/Users/user/Code/starter/node_modules/src/index.ts:167:10)
Error: The drizzle-seed package currently supports only PostgreSQL, MySQL, and SQLite databases. Please ensure your database is one of these supported types
at seedFunc (/Users/user/Code/starter/node_modules/src/index.ts:393:9)
at SeedPromise.then (/Users/user/Code/starter/node_modules/src/index.ts:167:10)
...

Error when fetching data from database view

The error I am getting when I am trying to fetch data from database view is NeonDbError: invalid input syntax for type integer: "NaN" The schema of database and view is ```...
No description

Can a CHECK constraint take sql builders (eq, lt, isNull)?

The types say these output SQL | undefined, while the check takes in SQL, so there is a type mismatch. The docs use ```import { sql } from "drizzle-orm"; import { check, int, sqliteTable, text } from "drizzle-orm/sqlite-core"; export const users = sqliteTable(...

How to handle multiple Durable Objects (with different schemas and migrations)

Is there a way to kind of have two Drizzle "projects" in one? I want to have two sets of schemas, and two of everything such that I can all one set of migrations on one Durable Object, and another on another Durable Object. This is because one worker allows for multiple Durable Objects to be defined and used...

Drizzle-kit incorrectly defaulting to @neondatabase/serverless driver

Hello, initially set up drizzle.config.ts and did a drizzle-kit generate and migrate and that worked. Now when I attempt to run a generate and migrate, the migrate fails, saying it can't open a websocket to the neon database. I am hosting pg in docker locally, my database url is such: DATABASE_URL=postgres://<user>:<password>@localhost:5432/drizzle-db ```...
Next