Drizzle Team

DT

Drizzle Team

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

Join

Data types for tables

Currently I receive this type from a db query... Is there a way to have a TS type which encapsulates it, so that I can define a variable of that type more easily?
No description

Neon and Drizzle ORM: Can my schema.ts create my tables in Neon?

As the title suggests, I was wondering if Drizzle ORM can create my tables in Neon from my schema.ts, or if I need to first create my tables in Neon with SQL, and then just create my schema.ts to reflect those tables. Thank you!...

Easiest way to add an array of objects?

Hey, I am trying to add an array of objects to my schema with postgres, how can I do this? there seems to be a pgArray but can't find a pgObject 👀 export const products = pgTable("products", { id: serial("id").primaryKey().unique(),...

drizzle-kit generate:pg - generates incorrect reference to table in another schema?

As im not super comfortable in pgsql, so im unsure if this is intended, or if its a bug with drizzle-kit. Im trying to create a fk reference to "auth"."users", inside my "public"."profiles" table. But drizzle-kit seems to not generate the script with correct reference to the database schema -, am i missing something?...

Help understanding relations

Hey all, just trying to get my head around relations. In this example we have a one-to-many relationship: ```ts export const users = mysqlTable("users", {...

Where does the onDelete on relation is applying ?

For instance : ```ts const product = pgTable('product', { logistics_id: serial('logistics_id') .references(() => logistics.id, { onDelete: 'cascade' })...

How to handle relations during insert?

Is this correct? Feels like I should be able to do it in one call, but values doesn't accept anything else ```ts const group = await db .insert(groups) .values({ name: inputs.name })...

Unwanted db.execute() behavior; trying to pass in an array instead of a record or its singular

When trying to pass an array (ex. number[], bigint[], string[]) that contains only one element into sql``​, it will be transformed into their non-list type (ex. number, bigint, string respectively). When I put two elements in, it then turns into a Postgres record, which is not what I want. What I expect is that the array stays an array. ...

TypeError: client.unsafe is not a function

I was attempting to run tests in a different monorepo folder (my trpc folder) than my core folder where drizzle is and ran into this . I am spinning up temp docker containers. It works in my core folder just fine but I can't figure out why i am getting this issue. Perhaps a drizzle bug? ```ts...
No description

What is the purpose of the _meta directory?

I am currently looking into using drizzle-kit for migrations and was wondering what the _meta directory does. Currently this part of the migration workflow is undocumented leaving several questions unanswered. Initially I tried to inspect the code myself and find out what it is used alas the source code of drizzle-kit is still not available (https://github.com/drizzle-team/drizzle-orm/issues/580). Currently I wonder if it has to be checked in to git, and under what circumstances it is required to read from as well as write to this directory. This would influence how drizzle migrations can/will be deployed on production: Does it have to be part of the deployed code, can it be non-existent, is it only needed for ephemeral data or does it have to persist data (i.e. in docker this would have to be a mounted volume), is it sufficient to only read from there (i.e. in docker this would allow increased security by marking the filesystem as readonly) etc... https://github.com/drizzle-team/drizzle-kit-mirror/issues/196...

`tablesFilter` cli arg "unknown option"

from the 'help' message
--tablesFilter Table name filters
--tablesFilter Table name filters
...

[BUG] Multi schema tables with same name

I have two tables with the same name in two different schemas. Drizzle seem to not take into account the schema when generating the SQL, and it generates only one of the two tables. This heavily brakes a lot of functionality

many-to-may relation

How do i define relation like a post probably has many comments that nested, for example a person can reply to other person's comment, ``` export const comments = mysqlTable( 'comments',{ id: serial('id').primaryKey(),...

Responses are coming back with Capitalized table names

When I run queries and joins, my table names are coming back with uppercase table names which breaks my models and UI that has existed with lowercase further down the chain. Any way to force everything to be lowercase? For example: ``` [...

TypeError: Seems like the schema generic is missing - did you forget to add it to your DB type?

How can I solve the following generic error relating to the db.query.users in my code below? ```bash Property 'users' does not exist on type 'DrizzleTypeError<"Seems like the schema generic is missing - did you forget to add it to your DB type?"> | { [x: string]:RelationalQueryBuilder<ExtractTablesWithRelations<any>, { ...; }>; }'. Property 'users' does not exist on type 'DrizzleTypeError<"Seems like the schema generic is missing - did you forget to add it to your DB type?">'.ts(2339)...

Can I create tables at runtime?

Is it possible to create a user-specific schema and then generate tables within that schema when a user signs up?

Execute is not exist on a type LibSQLDatabase

const url = env.TURSO_DB_URL if (url === undefined) { throw new Error('TURSO_DB_URL is not defined'); } ...

Transactions, PgBouncer/Supavisor, prepared statements

okay... i have spent way to long trying to figure out why when using transactions and a pooler on transaction mode it causes the connection to reset mid transaction statement causing a prepared statement 'name' does not exist which was very hard to debug. still don't fully understand why transaction won't work i've tried everything i could find setting params binary_parameters=yes (not even sure what this does, resetting database server (supabase). using a direct connection worked but wasn't something i could do forever. so my fix was.... just remove transactions from my endpoints (which sucks but it is what it is) ...

how enable wal for sqlite with drizzle ?

how enable wal for sqlite with drizzle ?