PHPackages                             myparcelcom/concurrency-safe-migrations - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. myparcelcom/concurrency-safe-migrations

ActiveLibrary[Database &amp; ORM](/categories/database)

myparcelcom/concurrency-safe-migrations
=======================================

Provides an artisan command that runs migrations but prevents execution at the same time

v0.1.3(5y ago)150.9k↓22.9%Apache-2.0PHPPHP &gt;=7.3

Since Mar 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/MyParcelCOM/concurrency-safe-migrations)[ Packagist](https://packagist.org/packages/myparcelcom/concurrency-safe-migrations)[ RSS](/packages/myparcelcom-concurrency-safe-migrations/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

Concurrency-safe migrations for Laravel
=======================================

[](#concurrency-safe-migrations-for-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/e9c0db2d6e98f58281ae0faa3bf8b1bc849f90e10e07277c651e6dd92cbeb599/68747470733a2f2f706f7365722e707567782e6f72672f6d7970617263656c636f6d2f636f6e63757272656e63792d736166652d6d6967726174696f6e732f76)](//packagist.org/packages/myparcelcom/concurrency-safe-migrations) [![Total Downloads](https://camo.githubusercontent.com/b79e6a7b4771a72c59ac7d974ad1ff56e9276899907d7467aeb986fc7302adc9/68747470733a2f2f706f7365722e707567782e6f72672f6d7970617263656c636f6d2f636f6e63757272656e63792d736166652d6d6967726174696f6e732f646f776e6c6f616473)](//packagist.org/packages/myparcelcom/concurrency-safe-migrations) [![Latest Unstable Version](https://camo.githubusercontent.com/58d94867f31ee75e0670a0f6d4555dd2071c3eb3e4655edb09fb00d9a2a8ed2c/68747470733a2f2f706f7365722e707567782e6f72672f6d7970617263656c636f6d2f636f6e63757272656e63792d736166652d6d6967726174696f6e732f762f756e737461626c65)](//packagist.org/packages/myparcelcom/concurrency-safe-migrations) [![License](https://camo.githubusercontent.com/4f8ed0a7b33aaf6a6d345c79119a846545926b99ee88550aef0dc4ba1f1ac815/68747470733a2f2f706f7365722e707567782e6f72672f6d7970617263656c636f6d2f636f6e63757272656e63792d736166652d6d6967726174696f6e732f6c6963656e7365)](//packagist.org/packages/myparcelcom/concurrency-safe-migrations)

Overview
--------

[](#overview)

This library ships the command `migrate:safe` for Laravel which executes the `migrate` artisan command in concurrency-safe manner using the Laravel atomic locks.

Installation
------------

[](#installation)

First, include the `myparcelcom/concurrency-safe-migrations` package in your composer dependencies:

```
composer require myparcelcom/concurrency-safe-migrations
```

Simply register the MigrateSafe command with your console Kernel:

```
class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        \MyParcelCom\ConcurrencySafeMigrations\Commands\Migrate::class
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')->hourly();
    }
}
```

Configuration
-------------

[](#configuration)

All options available with the `migrate` command can be passed to `migrate:safe` too. In addition, you can configure the atomic lock settings too:

- `--lock-ttl` - pass custom maximum lock ttl (in seconds). The `migrate:safe` will automatically release the lock once done. However, it is useful to put some ttl in failure cases where the container dies and lock is not released. Default value is 60 seconds
- `--cache-store` - select a specific Cache store. When omitted the default cache store is selected. The cache store **is required to work with atomic locks.**
- `--key-id` - enter custom cache lock key. When omitted the `APP_NAME` and current application environments are used to compose a key

Background
----------

[](#background)

Running migrations using `migrate:safe` assures that your application will not execute migrations at the same time. This could be a problem if you want to automate running migrations for your app but for whatever reason you cannot assure that the `migrate` command will be ran only once per deployment.

An example application is deploying a Laravel application on Kubernetes using [Flux](https://fluxcd.io/). Flux reconciles changes from Git in declarative way. Therefore, it becomes difficult to activate migrations upon deployment using a Job.

`migrate:safe` allows developers to attach init containers to deployment pods and only one will execute the migrations.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

4

Last Release

1900d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3841efa190ba5131014f8855131e3d38ef5ccd57c51000966348108e63c83612?d=identicon)[myparcelcom](/maintainers/myparcelcom)

---

Top Contributors

[![yoan-myparcel](https://avatars.githubusercontent.com/u/46448148?v=4)](https://github.com/yoan-myparcel "yoan-myparcel (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/myparcelcom-concurrency-safe-migrations/health.svg)

```
[![Health](https://phpackages.com/badges/myparcelcom-concurrency-safe-migrations/health.svg)](https://phpackages.com/packages/myparcelcom-concurrency-safe-migrations)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11120.2M21](/packages/anourvalar-eloquent-serialize)[overtrue/laravel-versionable

Make Laravel model versionable.

585308.0k5](/packages/overtrue-laravel-versionable)[abbasudo/laravel-purity

elegant way to add filter and sort in laravel

514330.5k1](/packages/abbasudo-laravel-purity)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)[dragon-code/laravel-deploy-operations

Performing any actions during the deployment process

240173.5k2](/packages/dragon-code-laravel-deploy-operations)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2928.9k7](/packages/stayallive-laravel-eloquent-observable)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
