PHPackages                             mll-lab/laravel-conditional-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. mll-lab/laravel-conditional-migrations

Abandoned → [mll-lab/laravel-utils](/?search=mll-lab%2Flaravel-utils)ArchivedLibrary[Database &amp; ORM](/categories/database)

mll-lab/laravel-conditional-migrations
======================================

Run your Laravel migrations only when you want them to

v3.1.1(3y ago)158.4k↓83.1%2MITPHPPHP ^7.3 || ^8

Since Mar 28Pushed 3y agoCompare

[ Source](https://github.com/mll-lab/laravel-conditional-migrations)[ Packagist](https://packagist.org/packages/mll-lab/laravel-conditional-migrations)[ RSS](/packages/mll-lab-laravel-conditional-migrations/feed)WikiDiscussions master Synced yesterday

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

Laravel Conditional Migrations
==============================

[](#laravel-conditional-migrations)

Deprecated
----------

[](#deprecated)

This package is deprecated in favor of  and will no longer be updated.

[![CI Status](https://github.com/mll-lab/laravel-conditional-migrations/workflows/Continuous%20Integration/badge.svg)](https://github.com/mll-lab/laravel-conditional-migrations/actions)[![codecov](https://camo.githubusercontent.com/1221d865ff7f06cf0cf917f954155ce6d0d86eb0966a44684f675b9c84f836c9/68747470733a2f2f636f6465636f762e696f2f67682f6d6c6c2d6c61622f6c61726176656c2d636f6e646974696f6e616c2d6d6967726174696f6e732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/mll-lab/laravel-conditional-migrations)

[![Packagist](https://camo.githubusercontent.com/e429921aebfb13a452fc1ba40b17ddb1e82cd114e3a8d43571e330888a01a4c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6c6c2d6c61622f6c61726176656c2d636f6e646974696f6e616c2d6d6967726174696f6e732e737667)](https://packagist.org/packages/mll-lab/laravel-conditional-migrations)[![Latest Stable Version](https://camo.githubusercontent.com/a30091262ae367e102e2863d2c1255a35ebd73494ad5d48edfd33a5939e6f361/68747470733a2f2f706f7365722e707567782e6f72672f6d6c6c2d6c61622f6c61726176656c2d636f6e646974696f6e616c2d6d6967726174696f6e732f762f737461626c65)](https://packagist.org/packages/mll-lab/laravel-conditional-migrations)[![GitHub license](https://camo.githubusercontent.com/1337967e251c9523e974e9d17998be460f91b4b0333a1aad6e1026f663cdf2c3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6c6c2d6c61622f6c61726176656c2d636f6e646974696f6e616c2d6d6967726174696f6e732e737667)](https://github.com/mll-lab/laravel-conditional-migrations/blob/master/LICENSE)

Run migrations only if a condition is true

Based on

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

[](#installation)

Via [composer](http://getcomposer.org):

```
composer require mll-lab/laravel-conditional-migrations

```

Usage
-----

[](#usage)

To run a migration conditionally, implement the `ConditionalMigration`interface and its `->shouldRun()` method:

```
use MLL\ConditionalMigrations\Contracts\ConditionalMigration;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Carbon;

class DoSomethingVeryIntensive extends Migration implements ConditionalMigration
{
    public function up() { ... }
    public function down() { ... }

    public function shouldRun(): bool
    {
        return (new Carbon('1 AM'))->lessThan(now())
            && (new Carbon('2 AM'))->greaterThan(now());
    }
}
```

The code snippet above will make sure the `do_something_very_intensive` migration will be skipped unless it is executed between 1 AM and 2 AM. This can be useful if your migration does something that should not be run during the daytime, like adding an index to a table containing lots of data.

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

[](#configuration)

You can optionally publish the configuration file:

```
php artisan vendor:publish --tags=conditional-migrations-config

```

This will create the file `config/conditional-migrations.php`.

The `always_run` option allows you to overrule the conditions set in individual migrations.

```
'always_run' => env('APP_DEBUG', false),
```

You can also use a closure if you want to do more advanced calculations:

```
'always_run' => function (): bool {
    // calculate if migrations should always run
},
```

Changelog
---------

[](#changelog)

All notable changes to this project are documented in [`CHANGELOG.md`](CHANGELOG.md).

Contributing
------------

[](#contributing)

Contributions are welcome, see [CONTRIBUTING.md](CONTRIBUTING.md).

License
-------

[](#license)

See [LICENSE.md](LICENSE.md).

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 96% 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 ~355 days

Recently: every ~231 days

Total

6

Last Release

1239d ago

Major Versions

v1.0.0 → v2.0.02020-07-30

v2.0.1 → v3.0.02020-12-10

PHP version history (4 changes)v1.0.0PHP ^7.0

v2.0.0PHP ^7.1

v2.0.1PHP ^7.2

v3.0.0PHP ^7.3 || ^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ff5d1af2c0f601f7ed7e75e15be0aa4c062149b57fd5aace4e44cc37b8b7a40?d=identicon)[spawnia](/maintainers/spawnia)

---

Top Contributors

[![spawnia](https://avatars.githubusercontent.com/u/12158000?v=4)](https://github.com/spawnia "spawnia (24 commits)")[![svenluijten](https://avatars.githubusercontent.com/u/11269635?v=4)](https://github.com/svenluijten "svenluijten (1 commits)")

---

Tags

phplaraveldatabasemigrations

### Embed Badge

![Health badge](/badges/mll-lab-laravel-conditional-migrations/health.svg)

```
[![Health](https://phpackages.com/badges/mll-lab-laravel-conditional-migrations/health.svg)](https://phpackages.com/packages/mll-lab-laravel-conditional-migrations)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11223.5M33](/packages/anourvalar-eloquent-serialize)[nwidart/db-exporter

Export your database quickly and easily as a Laravel Migration and all the data as a Seeder class.

37739.1k](/packages/nwidart-db-exporter)[umbrellio/laravel-pg-extensions

Extensions for Postgres Laravel

103451.2k1](/packages/umbrellio-laravel-pg-extensions)[wayofdev/laravel-cycle-orm-adapter

🔥 A Laravel adapter for CycleORM, providing seamless integration of the Cycle DataMapper ORM for advanced database handling and object mapping in PHP applications.

3535.8k3](/packages/wayofdev-laravel-cycle-orm-adapter)[elimuswift/db-exporter

Export your database quickly and easily as a Laravel Migration and all the data as a Seeder class.

364.7k](/packages/elimuswift-db-exporter)

PHPackages © 2026

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