Drizzle Team

DT

Drizzle Team

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

Join

Need help with ops.sql in the where clause

I'm trying to query my database for customers WHERE firstName / lastName is like a given string and my current solution is not working Still not exactly sure on how to use the ops.sql function in the case of my where clause, I tried looking at the docs but their isn't too much documented for this Help or pointing me to the right direction would be appreciated, Thanks...

Drizzle-kit hangs after push or studio

So after executing drizzle push or studio, it hangs after "Reading config file" Yesterday was working, and I did not change my drizzle config file, the only thing i did in between was I changed my docker compose config to persist data, yesterday it wasnt, and today I restarted docker so it deleted the db because the new docker config wasnt loaded yet, but the database is online and working well Normally for example using studio, it would show after the reading config file this...
No description

Only return single result

So when selecting a column from a specific row, there can only be single value, but drizzle always returns that as array

User Settings architecture

Hey, I am very new to everything related with backend and I recently started my full stack side project. The application will have "modules" for the user to choose from, they are stored in the DB: ``` export const user = pgTable('user', {...

Drizzle Studio Infinite Load - 404 Error in console for http://localhost:4983/

Hey I 'npx drizzle-kit generate' and 'npx tsx db/migrate.ts' fine and it goes to my supabase database but when I run 'npx drizzle-kit studio' it says it spins up in the console but when i go to https://local.drizzle.studio/ I get infinite loading screen and console index.js:13800

GET http://localhost:4983/init 404 (Not Found) ...

Prisma MySql Integration returns wrong keys in queries

```typescript const counted = await tx .select({ count: count(), })...

Prod database and Test database in Drizzle

I would like to know how you are dealing with having a test (or dev) database in your projects beside the prod database. As I'm using postgre, all my environments are in the same database, just with different schemas. How should that reflect in my drizzle files ? Should I declare each table and each column 3 times ? (for prod, dev and test) ...

Copying Data from Backedup Sqlite

I am using better-sqlite3 with multiciphers. I wish to add a feature where user can backup their current database and load it in future. I have backed up successfully. How to load those backed up data into the current db. I have drop all tables in the current db. and load tables and data from the backed up db.

Update primary key from integer to text

Hi everyone, Im currently working on authorization schemas for my project. I have migrated and pushed a schema where all models have id (pk) as integers (see image of schema). I now want to change all these from integer to text. When I try to run
pnpm drizzle-kit push
pnpm drizzle-kit push
I get the following ALTER: ...
No description

Deploying React/NodeJS

Hi, did anyone ever deploy this to production using nodejs as backend and reactjs as front? The internet looks pretty empty on this. I have no experience with deploying this as a monorepo....

[sqlite] How to order by rowid?

Having a query like: ``` db.query.countryTable.findAll({ where: eq(countryTable.continentId, continentId),...

Formatting date_of_birth as MM-DD-YYYY

What's the best way of doing this? date_of_birth: varchar("date_of_birth", { length: 10 }).notNull() That's what I have so far, but I need it to be MM-DD-YYYY. It needs to be this way because of the API I need to sync with. ...

Drizzle misses some schema files

Hey, I just noticed that the command bun run drizzle-kit generate and drizzle-kit push does not generate migrations or pushes some of the tables I have defined in my schema files. Only three tables get applied in the database no matter how often I retry the commands. My config looks like this: ```ts import { defineConfig } from 'drizzle-kit' export default defineConfig({...
No description

Migrating a local Cloudflare D1 database

I have a Cloudflare Worker with a few environments and databases. I've figured out how to migrate my staging and prod databases via this guide: https://orm.drizzle.team/learn/guides/d1-http-with-drizzle-kit. What I want to do now, is also run those migrations on my local database. This script allows me to access my local database, for example: yarn run wrangler d1 execute staging_db_1 --env=dev --local --file=./drop_tables.sql. How can I invoke drizzle-kit commands to run against my local database? I've tried removing the driver and dbCredentials values from the config in drizzle.config.ts, but I get Error Please provide required params: [x] url: undefined. I don't konw what URL I'd be expected to use if I'm drizzle-kit migrating a local database....

Working with the result of db.execute() (mysql2)

(TypeScript newbie here.) In my (SvelteKit) application I want to (health) check if certain database tables exist when the user visits the main page. What I tried: ```js const [ rows, fields] = await db.execute(...

Nested queries

Based on the provided schema, how to react the query to fetch first 25 posts a long with their comments and reactions, and each comment have it's own reaction, anyone have any ideas? ``ts export const now = () => sql<Date>now()` export const post = pgTable('posts', {...

How do I dynamically insert multiple encrypted values?

```ts const encryptedEmails = emails.map(email => encryptColumn(email)); const fetchedUsers = await db .select({...

Providing optional columns to insert query results in type error

I have this table ```ts export const team = pgTable( 'Team', {...
No description

Inferring types for nested objects

I need help on how to setup the types for the data returned so I can get correct autocomplete:

Cannot push postgres

I am initiating the db schema useing drizzlekit, but for some reason I can only push once and the second time it throws an error this is me running "pnpm drizzle-kit push" for the first time ```sh root@f2771f2cc095:/app# pnpm drizzle-kit push...