Run patches migration style in your Laravel applications.
Fund package maintenance!
Installs: 11 261
Open Issues: 1
- php: ^8.0
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.1
- friendsofphp/php-cs-fixer: ^3.1
- orchestra/testbench: ^7.0
- phpunit/phpunit: ^9.3
- spatie/laravel-ray: ^1.9
This package is auto-updated.
Last update: 2023-02-24 04:47:35 UTC
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
php artisan make:patch patch_1_0_0
This created a timestamped patch file under database/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:
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.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.