https://github.com/netsells/laravel-mutex-migrations
Run mutually exclusive migrations from more than one server at a time.
https://github.com/netsells/laravel-mutex-migrations
Last synced: 25 days ago
JSON representation
Run mutually exclusive migrations from more than one server at a time.
- Host: GitHub
- URL: https://github.com/netsells/laravel-mutex-migrations
- Owner: netsells
- Created: 2022-10-17T12:11:20.000Z (over 2 years ago)
- Default Branch: 3.x
- Last Pushed: 2025-03-07T17:01:04.000Z (2 months ago)
- Last Synced: 2025-04-15T09:12:03.997Z (25 days ago)
- Language: PHP
- Size: 52.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Mutex Migrations for Laravel
============================Run mutually exclusive migrations from more than one server at a time.
Using Laravel's functionality for [Atomic Locks](https://laravel.com/docs/9.x/cache#atomic-locks), this package extends the built-in `MigrateCommand` class to allow migrations to be run safely when there is the chance that they may be run concurrently against the same database.
## Installation
Install the package with:
`composer require netsells/laravel-mutex-migrations`
Optionally publish the package config file:
`php artisan vendor:publish --tag=mutex-migrations-config`
## Usage
Running a mutex migration using the default `database` store requires the existence of a table to store cache locks. If it does not exist the command will automatically fallback to a standard migration.
`php artisan migrate --mutex`
If two or more migrations happen to run concurrently, the first to acquire a lock will block the next one from running until it has finished, or until the lock times out - after 60 seconds, by default.
## Testing
`./vendor/bin/phpunit`