Run patches migration style in your Laravel applications.

Fund package maintenance!

v2.0.1 2022-02-26 15:39 UTC

This package is auto-updated.

Last update: 2023-02-24 04:47:35 UTC


Package Logo

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Enjoying this package? Buy me a beer 🍺

This package generates patch files in the same fashion Laravel generates migrations. Each file is timestamped with an up and a down method and is associated with a batch. You may run or rollback patches with the commands below.

This is a very simple package. It runs whatever is in your up and down methods on each patch in the order the patches are defined. It currently does not handle any errors or database transactions, please make sure you account for everything and have a backup plan when running patches in production.


You can install the package via composer:

composer require rappasoft/laravel-patches

You can publish the config file with:

php artisan vendor:publish --provider="Rappasoft\LaravelPatches\LaravelPatchesServiceProvider" --tag="laravel-patches-config"

You can publish and run the migrations with:

php artisan vendor:publish --provider="Rappasoft\LaravelPatches\LaravelPatchesServiceProvider" --tag="laravel-patches-migrations"
php artisan migrate


Making Patches

php artisan make:patch patch_1_0_0

This created a timestamped patch file under database/patches.

Running Patches

To run all available patches:

php artisan patch

To run each available patch in its own batch:

php artisan patch --step

To force the patches to run in production (deploy scripts, etc.):

php artisan patch --force

Rolling Back Patches

To rollback all patches of the last batch:

php artisan patch:rollback

To rollback the last X patches regardless of batch:

php artisan patch:rollback --step=X

Patch File Helpers

You may use the following helper commands from your patch files:

Log a line to the patches log column (up method only):

$this->log('10 users modified');

Call an Artisan command with options:

$this->call($command, $parameters);

Call a seeder by class name:


Truncate a table by name:


Note: Does not disable foreign key checks.

Please feel free to PR new helpers.


composer test


Please see CHANGELOG for more information on what has changed recently.


Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.



The MIT License (MIT). Please see License File for more information.