drizzle-team / drizzle-team/drizzle-orm

[BUG]: I get `cannot insert multiple commands into a prepared statement` when migrations more than one

Open
#2,794 4 comments 4 reactions 0 assignees View on GitHub
bug drizzle/kit priority
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### What version of `drizzle-orm` are you using?

0.33.0

### What version of `drizzle-kit` are you using?

0.24.0

### Describe the Bug

I'm writing tests and mocking postgres driver to pglite (yes, it's very cool), but I can't apply migrations when they're in `meta/_journal.json` more than 1

```ts
import { mock } from "bun:test";
import { PGlite } from "@electric-sql/pglite";
import { drizzle } from "drizzle-orm/pglite";
import { migrate } from "drizzle-orm/pglite/migrator";

const pglite = new PGlite();
const db = drizzle(pglite);

await migrate(db, {
migrationsFolder: "../../packages/db/drizzle",
});

mock.module("postgres", () => ({ default: () => pglite }));
mock.module("drizzle-orm/postgres-js", () => ({ drizzle }));
```

Based on the error, I found workaround - you need to create a new folder for migration and delete it every time (so that there are no more than one migrations)

My example

```sh
bunx drizzle-kit generate --config .\mock.config.ts
```
```ts
// @filename: mock.config.ts
import type { Config } from "drizzle-kit";

export default {
schema: "./src/schema.ts",
out: "./drizzle-mocks", // i change out to another than "drizzle" folder
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL as string,
},
} satisfies Config;
```

Drizzle is great!

### Expected behavior

_No response_

### Environment & setup

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.