Skip to content

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

@MatanYadaev

Description

@MatanYadaev

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.

Environment & setup

Postgres 15.3

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdrizzle/kitpriorityWill be worked on next

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions