drizzle-team / drizzle-team/drizzle-orm

[BUG]: `migrate` isn't protected against simultaneous execution

Open
#874 26 comments 21 reactions 1 assignee Claimed by @AndriiSherman 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.27.0

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

0.19.3

### Describe the Bug

There's no protection against the `migrate` function being executed simultaneously multiple times.

Executing `await Promise.all([migrate(), migrate(), migrate()])` will lead to the migrations running three times and potentially causing problems.

### Expected behavior

The `migrate` function should be designed to execute only once at any given time, probably by using a locking mechanism.

For reference, Prisma uses [Advisory Locking](https://www.prisma.io/docs/concepts/components/prisma-migrate/migrate-development-production#advisory-locking).

### Environment & setup

Postgres 15.3

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.