Drizzle Team

DT

Drizzle Team

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

Join

Permission denied for table schema_migrations

I created a migration from supabase to drizzle and am encountering this error. What could be the reason? Happy to provide more context.

env.local not using in drizzle

I'm using t3/env and if I have only .env.local and run drizzle-kit migrate i get error Invalid environment variables if I created .env it's work

Drizzle Migration but with TS code

Does anyone have an idea about running TS code during migration. I'm thinking of moving from knex.js to drizzle (a migration part). In knex.js, it's quite convenient since the migration is TS code, example: if I want to alter a nullable column to non-nullable column, I would want to run a script to set value for it before alter it and to do that, I could use a complex update like ... ```...

Joins with the Query API

Hi. I want to use .query to have nested queries for subitems, but i would also like to execute table joins within the API. Is it possible to achieve this somehow?

Disable selection in table creation

i have column in ai_model table named api_key , i do not want that in any response and want only when I actually select for it like in typeorm @CreateDateColumn({ select: false, type: 'timestamp' }) createdAt: Date;...

Timeout issues on vercel

Hey everyone, I have a remix app hosted on vercel along with a turso DB (functions and db are on the same region) and i have been facing some unexpected issues lately. On my index route im running a query that is often expected to return a larger number of rows, and since im using the query syntax it also aggregates relations. When running a query inside of my loader function here https://github.com/VaggelisKa/my-desk/blob/main/app/routes/_index.tsx it often fails on vercel because of a timeout. While on my local dev environment the query executed and resolves in sub 1s time. The same for when i run the raw sql on the DB. ...

drizzle-kit migrate error

When I drizzle-kit generate a schema change of
ALTER TABLE `item` ADD `count` integer DEFAULT 0 NOT NULL;
ALTER TABLE `item` ADD `count` integer DEFAULT 0 NOT NULL;
and then run drizzle-kit migrate how come I get the below error that is about another unrelated credential table? ...

trouble creating Enum

Hi everyone, here's my code: ```javascript import { paymentPlansNames } from 'misc/payment-plans'; import { pgTable, pgEnum, json, varchar } from 'drizzle-orm/pg-core';...
Solution:
export const subscriptionPlanEnum = pgEnum('subscription_name', paymentPlansNames);
export const frequencyEnum = pgEnum('frequency', ['monthly', 'yearly']);
export const subscriptionPlanEnum = pgEnum('subscription_name', paymentPlansNames);
export const frequencyEnum = pgEnum('frequency', ['monthly', 'yearly']);
...

Help with Join query

Hi all, I have this three tables: users (id, name, email) account (id, username, public) userAccounts (user_id, account_id, role)...

syntax atomic transaction d1 not working

getting [ERROR] To execute a transaction, please use the state.storage.transaction() API instead of the SQL BEGIN TRANSACTION or SAVEPOINT statements. The JavaScript API is safer because it will automatically roll back on exceptions, and because it interacts correctly with Durable Objects' automatic atomic write coalescing. ...

Migration Error - already on Production

`787 | query && (query.cursorFn || query.describeFirst) && write(Sync) 788 | const error = Errors.postgres(parseError(x)) 789 | query && query.retried 790 | ? errored(query.retried) 791 | : query && query.prepared && retryRoutines.has(error.routine)...

How can I handle ID collisions

I know that it is very unlikely for an id collision to happen but I would like to know possible ways to handle it. Is there an easy way that I can do that in drizzle?

drizzle-typebox loses typechecking when used from another package

I'm setting up a project with a monorepo (available at https://github.com/trilliumlab/trail-eyes-monorepo/blob/3459d8014508365d256db5cc8b088e880f8b29f6/) I have a separate package for the database that can be shared with all my apps. I use typebox throughout the project, so the database package uses drizzle-typebox and createInsertSchema to generate my typebox schemas. For some reason, it seems I lose typing from any schemas created with drizzle-typebox when I try to use them outside of the database package. This doesn't seem to happen with typebox schemas I create myself. ...

sharding orchestrator support suggestion

dunno if this is the right place to make a suggestion, but this would be such a good feature to support sharding especially for D1 db given their constraints (10 gb) and all the complexity that comes along with it aka "migrations"

Using generics with Table type

hey there, I'm trying to create a generic function, something like this: ```ts function insertWithLogger<DataType>(data: DataType[], table: SomeTableType<Data>) { logger.info("Inserting data, wow!") db.insert(table).values(data)...

TypeError: Cannot read properties of undefined (reading 'dialect')

Hello, I am trying out Drizzle for the first time with javascript and Nodejs. I am trying out the migration part of Drizzle and I have setup everything that the docs said to me. But when I run node db/migrate.js I get the error undefined (reading 'dialect'). Why is this? ```js // config import { defineConfig } from 'drizzle-kit';...

Postgres Schema (namespace)

Does anyone have a minimal example of a Drizzle postgres schema that uses the Postgres "Schema" (namespace) feature? On drizzle kit push I keep getting error: schema "meow" does not exist. ```ts...

cannot push schema changes to db after successfully running migration.

Hello everyone, I am trying to push the schema that i have just created using npx drizzle-kit generate and after that when i run npx drizzle-kit push it gets stuck on Pulling schema from database... doesn't throw any error. same thing with drzzle-studion why is it so ?
No description

Batch Update multiple rows.

Is there a way to do batch update for multiple queries using update ... from syntax ? for example : ``` update test as t set...

Migration Halts

I was working on Migrating a .sql file that I sucesfully generated with drizzle generate. The issue I ran into was that the Migration process has been running for several minutes. The .sql file is pretty lightweight and does not contain too much sql. ```javascript -- generated sql import { pgTable, serial, text, varchar, timestamp, uuid } from "drizzle-orm/pg-core";...
No description