Drizzle Team

DT

Drizzle Team

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

Join

How to fix TypeError: Cannot read properties of undefined (reading 'columns')?

TypeError: Cannot read properties of undefined (reading 'columns') ❯ PgDialect.buildRelationalQueryWithoutPK node_modules/src/pg-core/dialect.ts:1170:32 ❯ PgDialect.buildRelationalQueryWithoutPK node_modules/src/pg-core/dialect.ts:1294:32 ❯ QueryPromise._getQuery node_modules/src/pg-core/query-builders/query.ts:117:23 ❯ QueryPromise._toSQL node_modules/src/pg-core/query-builders/query.ts:134:22...

drizzle-kit push:sqlite no working

I have been using this command for the past year and it has worked, it also worked about 3 days ago. I have set my drizzle.config.ts file to:
driver: "turso", verbose: true, strict: true, breakpoints: true,...

is there a nice way to say getTableColumns - but without columns id and foo?

Is there an easy way to omit columns? This is what I came up with but... ```...

try to push : schema "XXX" does not exist

When I try to add a custom schema, the push command dont works : ```tsx export const quizSchema = pgSchema("quiz"); export const answerTypeEnum = quizSchema.enum("answer_type", ["single_choice", "multiple_choice", "boolean", "text", "number"]);...
Solution:
okay ive found. I had to add schemaFilter: ['public', 'quiz'], in the drizzle.config.ts file

Install latest version of drizzle-orm

I am trying to use drizzle orm with drizzle kit. I have everything configured but keep getting a message from drizzle-kit to install the latest version. ```sh ❯ pnpx drizzle-kit generate No config path provided, using default 'drizzle.config.ts'...

Count issues with libsql (Turso)

``const locations = await db.query.locationsTable.findMany({ extras(fields, { sql }) { return { groupsCount: sql<number> (SELECT COUNT(*) ...

Recommended Docker Compose Workflow

Hey all, I'm new to making full stack applications and am working with Drizzle to make mine. I have a question on what the best practice is when using databases that are spun up using Docker Compose and how to initialize them with Drizzle tables. I have the following docker-compose.yaml ...

$count with relation api returning wrong values ( 2 instead of 0)

```ts async function findProjectById(id: number) { return await db.query.projects.findFirst({ where: eq(projects.id, id), with: {...

Is it possible to have conditional foreign key relation?

``` export const booking = pgTable( 'booking', { id: generateUUIDV4AsPrimaryKey(),...

Missing schema from generated SQL when using `.toSQL()` on a query style SQL query.

I'm trying to get use .toSQL() on a query (db.query.someTable) but it doesn't include the schema for the target tables. I want to use the .toSQL() to then pass the SQL and params to electric-sql to sync things I'm running drizzle on the browser. I didn't find the PGLite driver tag to use....

insert from select

I am trying to convert a SQL query like this to drizzle: ``` INSERT INTO table_name (name) SELECT...

Drizzle zod infer wrong type

Using createInsertSchema* with a jsonb field number | null for month is transformed into any...
No description

How to handle multiple unique constraints with onConflictDoUpdate?

My postgres table has 2 unique constraints:
unique("unique_game").on(table.idTeamHome, table.idTeamAway, table.time),
unique("unique_id").on(table.idEvent),

unique("unique_game").on(table.idTeamHome, table.idTeamAway, table.time),
unique("unique_id").on(table.idEvent),

...

Best practices for inferring types in queries?

I'm refactoring my app and I'm trying to keep my schema as the single source for my data types, at least for my model data. Inferring types has worked wonders for inserting and making basic queries. However, for more complex queries with nested data I've tried to make intersection types matching the structure of the query result, but ts doesn't like that (the structure might not be identical), and explicit casting doesn't seem to work either. ...

Already exits error

Hey, I am trying to build an application by using neondb and drizzle-kit. On my local, I can trigger that script npx drizzle-kit migrate without an error, but when my application's build process on the vercel, I am getting that error
No description

TypeScript Error

I'm running into a TypeScript issue with Drizzle ORM & SingleStore integration. Issue: I'm trying to define a table using singlestoreTable from "drizzle-orm/singlestore-core", but TypeScript is throwing types-related errors. Here's my schema: ...

Is it possible to run migrations on a local dev D1 db?

How do I run migrations on my local D1 when running wrangler dev?

Cant figure out how to converting a sql query to drizzle syntax

I've been trying to figure out how to convert this query for almost two hours, I don't understand how these multiple with statements translates into the drizzle syntax, anyone knows? ```ts WITH review_dates AS ( SELECT DISTINCT DATE(${ReviewLog.createdAt}) AS review_date...

PostgresError: type "vector" does not exist

Hello! A while ago I was creating a project with drizzle + pgvector. I created the generate custom by putting CREATE EXTENSION vector; But now it tells me that the extension does not exist. What am I doing wrong? Has there been any update? I'm still a bit new to vectorization, sorry!...

Unable to update because it is saying field does not exist in schema

I am trying to update the keyword field in stores however I am getting the following error:
Object literal may only specify known properties, and 'keyword' does not exist in type '{ name?: string | SQL<unknown> | PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>; }'.ts(2353)
Object literal may only specify known properties, and 'keyword' does not exist in type '{ name?: string | SQL<unknown> | PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>; }'.ts(2353)
...
No description