Drizzle Team

DT

Drizzle Team

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

Join

Having Issues Pushing Database Schema

Hi I am getting this issue whenever I am trying to push the database schema. Any help would be greatly appreciated. ``` ❯ pnpm drizzle-kit push:mysql --schema=./Database/schema.ts drizzle-kit: v0.19.13 drizzle-orm: v0.28.6...

migration failed

code: ```js const migrationClient = postgres("postgresql://jer:admin@localhost:5432/test", { max: 1 }) async function main() {...

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

I am attempting to run db push, but I am getting this error above^^ does anyone know what might be going on?...

Nesting sqlite drizzle into a deeper location in my ts app, difficulties with src/ vs dist/

Hey! I'm very new to drizzle and trying to set up a very small drizzle instance for a service that reads a whole pile of json files and acts as a simple read-only information store. I got most of the setup to work. I have it at a location ``` src/...

syntax highlighting not working

I reinstalled the node_modules multiple times and it didnt fix my problem. This isnt suposed to look like this does it?
No description

Prepare raw sql query (Postgres)

Hi, I need to do a recursive query, so I think I need to use the magic sql operator to build it. Is it possible to make a prepared statement this way? I haven't been able to find a way, but something like db.prepare(sql`...`) would make sense to me.

packing migration files with the library

hey there, I'm trying to use migrate inside from a library consumer (i.e I have a @mycompany/db-lib that has doMigration and from my internal dev-app, I want to do something like: ```ts import { doMigrate } from '@mycompany/db-lib' export const onMigrateClick = () => {...

Any way to invoke a SQL function?

For ex: lets say I declare a SQL function CREATE OR REPLACE FUNCTION do_something() how do i invoke this function using Drizzle's interface?...

How to include array literals in raw sql?

I have an input array used for an order by using the array_position function - rather than passing the array as a single param, the call to:
.orderBy(sql`array_position(${ingredientNames}, ${entity.name})`);
.orderBy(sql`array_position(${ingredientNames}, ${entity.name})`);
...

MySQL Table Schemas

I need to generate the following structure of tables: 1. Sales 2.Sales .......

any way to automatically cast numeric types on retrieval?

I have a numeric field in a video table: ``` export const VideoTable = pgTable('videos', { id: uuid('id').primaryKey().defaultRandom(), height: integer('height'),...

Query in drizzle doesn't work

Error:
DrizzleError: No fields selected for table "usersToGroups" ("users_groups")
DrizzleError: No fields selected for table "usersToGroups" ("users_groups")
...
No description

Cannot read properties of undefined (reading 'referencedTable')

Seemingly getting this error out of nowhere. I believe it's related to the relations I defined, but can't quite figure out what is causing it specifically.

Relational query builder in mysql?

I cant find anything about how to implement this. Am I blind or is this impossible?

TransactionRollbackError

Need some help understanding TransactionRollbackError... Is this error saying the tx.rollback() function itself threw an error and that the rollback was unsuccessful, or just that the tx.rollback() function was called?...

PostgresError: null value in column "id" of relation "pairs" violates not-null constraint

Hello, I am fairly new to Drizzle and working with databases, so I am running into a problem that I am unsure how to solve and hope that you can help me with it. I use Directus CMS to create all of my tables. Then, I wrote schema.ts (using introspect and making a couple of manual changes). So, one of my tables looks like this:...

OnConflictDoNothing with mysql

Hi everyone, I want to use the on conflict do nothing method described here: https://orm.drizzle.team/docs/insert#onconflict-and-upsert-insert-or-update. But it seems to be that only onConflictDoUpdate is available. Is this database specific or Am I doing something wrong here? this is my query: ...

drizzle-kit introspect reorder tables

Here is the case: - I have a remote database. I made a backup and restore it locally - I ran: drizzle-kit introspect:pg --config=./database/drizzle/drizzle.config.ts - With different connections in the config: first for the remote DB and second for the local DB, I got different orders of tables in the generated schema...

Migration custom logger

Hey there, I'm want to run migration as part of my CI/CD, and would have liked the output of the migrate function to be passed to my custom logger function. is it something that is supported/planned? if not - i'd suggest adding two logging options infoLogger and errorLogger both of type (msg: string) => void thx...

why do snapshots not have the same name as the migrations?

Hey, loving dirzzle so far. Hit a snag recently. Me and my friend are collaborating on a project. We ended up in a merge conflict. Here is what happened: 1. We both created our separate branches from main....
No description