Drizzle Team

DT

Drizzle Team

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

Join

[Postgres] PostgresError: type X already exists.

PostgresError: type "media_types" already exists
PostgresError: type "media_types" already exists
I have SQL like this: CREATE TYPE "public"."media_types" AS ENUM('image', 'video');--> sta ...

Drizzle-kit not working as expected

If there is a file xyz.ts and it currently has one table and if I use npx drizzle-kit push it runs sucessfully I add one more table to same file and use the command again it throws error ```ts [itsmishra@Rajat ayanami]$ npx drizzle-kit push No config path provided, using default 'drizzle.config.ts' Reading config file '/home/itsmishra/ayanami/drizzle.config.ts'...

Postgres tables with same name but different schema

I have three users tables, each in different postgres schema. They have 3 columns in common: email, createdAt and updatedAt. When I try to make a relational query where I fetch a token with the user relation, the type of the user contains just those 3 columns, instead of all columns of that specific users table (image attached). Seems like it is an intersection of the types of those 3 users. Seems like the problem is that a relation is defined as: ``` Relations<"users", { ... }>...
No description

The signature with pgTable is depreciated.

The pgTable function with the callback function is depreciated? And If i remove the second argument to the function(the callback function), the depreciation message disappears.
No description

is it possible for a join table to have one of the relations reference a composite key?

i have the following: 1. contacts table - userId // this references the user's id per clerk (otherwise, this would really be basically a join table) - contactId // this references the contact's clerk user id - pk is composite of the aforementioned ids...

Can't migrate with pgPolicy and pgRoles

For context, this is my current setup, I cannot drizzle kit push to my schema and getthing an error saying: error: role "BODYSHOP_ADMIN" does not exist Roles.ts ```typescript...

Supabase SSL - ENAMETOOLONG when adding sslrootcert to dbCredentials url

I'm trying to connect to my supabase with ssl-enabled using drizzle-kit but I keep on getting ENAMETOOLONG. I'm encoding the certificate into the connection url, but it seems like I'm reaching the limits of path length. My code is literally the same as was posted by budivoogt: https://github.com/orgs/supabase/discussions/18710#discussioncomment-10614735...

I'm trying using $count, and it giving me fieldAlias missing. What should I do?

I'm on drizzle-orm 0.36.1 and drizzle-kit 0.28.0. My schema is something like below. For note, its oversimplified over my project. ```js export const item = pgTable(...
No description

Can i use "uniqueIndex" for that?

Hi, I was just wondering if ```export const contactToCompany = pgTable( "ContactToCompany", {...

TypeError: db.execute is not a function

import { drizzle } from 'drizzle-orm/better-sqlite3'; import Database from 'better-sqlite3'; const sqlite = new Database('sqlite.db'); const db = drizzle({ client: sqlite }); const result = await db.execute('select 1');...

Automatically convert binary to string

```typescript export const table = mysqlTable( 'table', { id: binary('id', { length: 16 }).notNull().primaryKey(),...

Drizzle-kit push - pgPolicy ignores using configuration

Policy: pgPolicy("Users can view their own active organization memberships", { for: "select", to: authenticatedRole, using: and(...

column is of type date but expression is of type text

So, I was trying this and it resulted in an error:
column \"date_of_birth\" is of type date but expression is of type text
column \"date_of_birth\" is of type date but expression is of type text
It happened when I tried updating multiple columns of multiple rows of a table. It doesn't happen when multiple columns of a single row are being updated. What causes this? I asked another person and they said that it's not necessarily a postgres issue and probably has somethi to do with drizzle orm....

Do prepared statement names matter?

Should we make sure that the names of prepared statements are unique in any way? If so, unique globally or within a block scope? For example, is this a problem within the same block? ```ts const prepared = db.select().from(customers).prepare("statement_name");...

Bun:SQLITE error with drizzle

trying to run drizzle studio and push changes using drizzle kit but having this error ``` Cannot find module 'bun' Require stack: - C:\projects\tasks-api\src\env.ts...

How do I get types for relationship queries?

``` // Users table export const users = pgTable('users', { id: serial('id').primaryKey(), email: varchar('email', { length: 255 }).notNull().unique(),...

Filter based on join data

Hi, would it be possible to query a list of student and filter by the name of its coach. The data is <student>.coach.fullname where coach is added as a with join. I would like to get every student that have a certain coach.

Using relation columns in where clause (Drizzle playground provided)

I have a one-to-one relationship with a schema defined like: https://drizzle.run/uwkkt8l10cgp5okr1r41tjfu When I run that query, I get the following error column agent.deleted does not exist. Why can't you reference relation columns in a top-level where clause? Is there a better way to do this without using the select API with joins?...

StatementTimeoutException: Request timed out

Hey! So I'm using SST v2 on my project. As database I'm using RDS Aurora (https://v2.sst.dev/databases#rds, https://v2.sst.dev/constructs/RDS) with PostgreSQL engine. I have followed the guide from SST docs and take a look on Drizzle docs too (https://orm.drizzle.team/docs/connect-aws-data-api-pg, https://orm.drizzle.team/docs/perf-serverless). But recently I noticed that I have run into StatementTimeoutException: Request timed out issue. I'm getting this error in SST console: `StatementTimeoutException: Request timed out at de_StatementTimeoutExceptionRes (file:///var/task/packages/functions/src/api/permissions/get-user-permissions.mjs:62242:21) at de_CommandError (file:///var/task/packages/functions/src/api/permissions/get-user-permissions.mjs:62064:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)...