Open kravetsone opened 2 months ago
I set this up with vitest and managed to get it working with more than one migration in my folder. I got tripped up on having the right path for migrationFolder
. This could be your issue depending on where you calling your test script from.
const client = new PGlite();
export const db = drizzle(client);
vi.mock("postgres", () => ({ default: () => client }));
vi.mock("drizzle-orm/postgres-js", () => ({ drizzle }));
// Apply migrations before each test
beforeEach(async () => {
await migrate(db, {
migrationsFolder: "./packages/core/migrations",
});
});
// Clean up the database after each test
afterEach(async () => {
await db.execute(sql`drop schema if exists public cascade`);
await db.execute(sql`create schema public`);
await db.execute(sql`drop schema if exists drizzle cascade`);
});
// Free up resources after all tests are done
afterAll(async () => {
client.close();
});
Here is the code: link
I was able to pin this down to missing --> statement-breakpoint
statements within migrations that I had manually changed. Adding those in between commands fixed the issue.
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 1Based 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
Drizzle is great!
Expected behavior
No response
Environment & setup
No response