Drizzle Team

DT

Drizzle Team

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

Join

When trying to push:mysql its warning that schema has changed and data will be lost when it hasnt.

· You're about to change projected_points column type from alter_table_alter_column_set_type to decimal with 689 items
THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED
· You're about to change projected_points column type from alter_table_alter_column_set_type to decimal with 689 items
THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED
No changes have been made ......

Invalid input value for enum

I have this enum definition as below and whenever I’m to make a request to save a data of the kind of the enum I always get back invalid input value for enum auth_type: “Form”, where as my enum was defined with uppercase. But if I use “form” it will accept it. Const authTypeEnum = pgEnum(“auth_type”, [“Form”, “Google”]); What could be the issues of this error?...

Share migrations in monorepo

I am using drizzle in a monorepo (npm workspaces with turborepo) within an internal package that is shared among multiple apps. It basically exports a bunch of functions that use drizzle behind the scenes. This works great, however I can't run migrations from within the apps that use the package, because the folder with the migrations is only available inside the package that contains drizzle. I would love to run the migrations on app startup using migrate from drizzle-orm/postgres-js/migrator like shown in the examples, but then I get the error that the migrations can't be found. The only solution I figured so far is to copy the migrations from the shared package to every app directory every time when I ran drizzle-kit generate. Can you think of any better solutions?...

Top-level await is not available in the configured target environment ("node14")

```typescript import type { Config } from "drizzle-kit"; import { getDbUrl } from "./src"; ...

How to migrate changes to a table

I'm trying to read up on drizzle and the first question that come to mind was how does migration works with database changes? The docs, https://orm.drizzle.team/docs/migrations, only shows the initial first migration. How are changes treated and what are the recommended way of doing them? Do I just update the schema.ts file and drizzle figure out what migration I need to run?

Postgres-js Migrate - Error: Can't find meta/_journal.json file [SOLVED]

I've gotten drizzle setup and running but I'm unable to run any migrations. I'm using postgres-js and created a migrate.ts file that i'm executing. Here is my code:...

Sveltekit Failed to resolve import "cloudflare:sockets"

I was trying to use drizzle orm in a sveltekit project with postgres run in a docker container, but i'm having the following error ```sh [plugin:vite:import-analysis] Failed to resolve import "cloudflare:sockets" from "node_modules.vite\deps\chunk-JJ5CRB2A.js?v=dcae3c33". Does the file exist? F:/Python/jira-clon-2/node_modules/.vite/deps/chunk-JJ5CRB2A.js:2908:44...

Unable to insert rows when using libsql

hey, i am using libsql on my local environment with drizzle but i am unable to insert anything in the database. the promises seem to be broken. i am on the latest drizzle orm and kit version. here is the code to reproduce:...

generate:pg - 0 Tables pnpm Monorepo

Seems to be related to this issue - https://github.com/drizzle-team/drizzle-kit-mirror/issues/24 I only have drizzle-orm/drizzle-kit installed in a single package in my repo. ```...

Bulk update in Postgres w/ Drizzle ?

I'm using PSQL and would really like if Drizzle supported bulk updates out-of-the-box. I've looked at the docs - but the only option I've seen is an UPSERT (ie. insert w/ onConflictDoUpdate) statement which I'm not fan of for this use case. I'd really like to be able to do a .update(table).set(arrayOfObjects) ! But it looks like it's not supported....

Problem when inserting new record

Hello guys, when I'm trying to insert new record, I'm getting this PG error null value in column "id" of relation "MagicLinks" violates not-null constraint and in my schema, I have id: uuid('id').primaryKey().defaultRandom()...

BUG: Prepared statements with placeholder values .execute() not working on postgres

I'm trying to execute a prepared statement with placeholder() values ```ts export const articlePreparedQueryNodePg = dbNodePg .select()...

Nullable self-reference table relation

``` typescript: No overload matches this call. Overload 1 of 2, '(left: Aliased<null>, right: AnyColumn | Placeholder<string, any> | SQLWrapper | null): SQL<unknown>', gave the following error. Argument of type 'MySqlInt<{ tableName: "cuentas"; name: "padre_id"; data: number; driverParam: string | number; notNull: false; hasDefault: false; }>' is not assignable to parameter of type 'Aliased<null>'. Type 'MySqlInt<{ tableName: "cuentas"; name: "padre_id"; data: number; driverParam: string | number; notNull: false; hasDefault: false; }>' is missing the following properties from type 'Aliased<null>': sql, fieldAlias, getSQL...

Support for relational queries with views

Hello! I was wondering if there are plans to add support for relational queries with views? I am not presently able to define relations on a view as it is expecting a table as the first argument. Thanks!...

Many to many relationship between one type

I'm making an application where I have users who are able to follow other users. This means that I need a many-to-many relationship, but both sides are the same type (a user). I'm not sure how to express this with drizzle's relations, as I'm not sure how to specify both sides of the relationship For example... ```ts export const Users = pgTable("users", {...

How can I order and/or limit rows from leftJoin?

I have two tables, groups and exams, exam must have only group, group can have many exams. I'm selecting from groups and I want to select the latest exam with it (order by timestamp column). But I can't find anything like it in the drizzle orm docs, is is possible?

Can someone help me understand these 2 examples using pool and client?

I'm reading through the docs and see that in the 2 Neon examples, they use a pool and client. From what I understand, pools support multiple requests and a client doesn't. The 2 questions I have are: - When would I want to close the pool or client? I would assume I would want to keep it open in production so that I wouldn't need to open the connection again. - Why would I use a client?...

Type Declaration with TypeScript in Monorepo failes

I am trying to setup a monorepo with moon and pnpm, where shema lives in an additional package and is imported by other apps. Is there any monorepo example? Currently I get following error:
../db/src/schema/products.ts(4,14): error TS2742: The inferred type of 'products' cannot be named without a reference to '../../node_modules/drizzle-orm/db.d-a6fe1b19.js'. This is likely not portable. A type annotation is necessary.
../db/src/schema/products.ts(4,14): error TS2742: The inferred type of 'products' cannot be named without a reference to '../../node_modules/drizzle-orm/db.d-a6fe1b19.js'. This is likely not portable. A type annotation is necessary.
...

Type error?

``` import { pgTable, serial, integer } from 'drizzle-orm/pg-core'; export const users = pgTable('users', { id: serial('id').primaryKey(),...

Unsafe argument of type `any` inside select where eq query

I am getting the following type error even though I am not passing parameters of type any. Correct me if I am wrong because I am a typescript begineer. Refer to the screenshots attached. ```ts...