Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Feature request: In-Database migration lock #425

Closed
joeyaurel opened this issue Apr 19, 2020 · 3 comments
Closed

Feature request: In-Database migration lock #425

joeyaurel opened this issue Apr 19, 2020 · 3 comments
Labels
datamodel-migrations kind/feature A request for a new feature. team/migrations Issue for team Migrations.

Comments

@joeyaurel
Copy link

Problem

Consider deploying a Node.js server twice (because of horizontal scaling; maybe load balancing), and both of them would call a prisma migrate up while deploying. What could happen now is that Node.js server 1 tries to migrate while Node.js server 2 also tries the same. This could maybe result in conflicts within the database.

Solution

A "In-Database" migration lock on a table designed specifically for locking.

Workflow would be as follows:

  • First prisma migrate up tries to create special table and maybe sets a boolean value indicating that a migration is running
  • Any other script now running prisma migrate up sees the lock in the table and skips the migration
  • When the initial prisma migrate up finishes, the lock within the database "unlocks"
@pantharshit00 pantharshit00 added the kind/feature A request for a new feature. label Apr 21, 2020
@albertoperdomo albertoperdomo added the team/migrations Issue for team Migrations. label Nov 25, 2020
@joeyaurel
Copy link
Author

@albertoperdomo Have you guys put a thought on this? :) Or is there a "best practice" to this kind of issue?

@tomhoule
Copy link
Contributor

tomhoule commented Dec 2, 2020

It is something we have plans for, it will come as soon as there is time to work on it: prisma/prisma-engines#1118

@tomhoule
Copy link
Contributor

Let's close this issue as a duplicate of prisma/prisma-engines#1118

Work on this is planned.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
datamodel-migrations kind/feature A request for a new feature. team/migrations Issue for team Migrations.
Projects
None yet
Development

No branches or pull requests

6 participants