Download the PHP package human018/laravel-patch without Composer
On this page you can find all versions of the php package human018/laravel-patch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download human018/laravel-patch
More information about human018/laravel-patch
Files in human018/laravel-patch
Package laravel-patch
Short Description Perform migrations and database patches within your Laravel application
License MIT
Informations about the package laravel-patch
Laravel Patch
Perform migrations and database patches within your Laravel application
At times you may need to run a database migration and then perform some kind of patch associated with the migration. This package will create both the migration and an associated patch command, it will listen for the migration event and then run the patch command automatically for you.
When might you use this package?
Example 1:
You're changing a model relationship to an immediate relationship (hasMany) rather than a distant relation (hasManyThrough). You need to add a new foreignId column to the target models table and then populate that column with the correct ID's. With this package you can create both the migration and the patch command and then run them within the same migration command.
Index
- Usage
- Requirements
- Download & Installation
- Performing Patches
- Migration Direction
- License
Usage
Requirements
- PHP 7.4
- Laravel 8
Download & Installation
Laravel will auto discover the package.
Performing Patches
Once installed a patch can be created by running the following command in line with the regular Laravel make:migration command.
This will generate both the migration and an associated patch command.
The package listens for when a migration event is fired, determines if there is an associated patch command and fires the command.
You will find Patch commands created in your projects 'Commands' folder under the subdirectory 'Patches', where you can perform any tasks that need to be done in line with this migration.
Migration Direction
The migration direction is passed to the Patch Command using the 'method' option.
So if you need to revert some changes you can detect the 'down' direction.
License
This project is licensed under the MIT License