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.
Installation
You can install the package via composer:
composer require rappasoft/laravel-patches
You can publish and run the migrations with:
php artisan vendor:publish --provider="Rappasoft\LaravelPatches\LaravelPatchesServiceProvider" --tag="laravel-patches-migrations"
php artisan migrate
Usage
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:
$this->seed($class);
Truncate a table by name:
$this->truncate($table);
Note: Does not disable foreign key checks.
Please feel free to PR new helpers.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.