jalameta / jps-patcher
Laravel patch scripts.
Installs: 9 573
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- illuminate/console: ^7.0
- illuminate/database: ^7.0
This package is auto-updated.
Last update: 2022-08-02 14:06:25 UTC
README
A (migration like) patcher for a smoldering production update.
Already tested on:
- Laravel: 6.* | 7.* | 8.*
Background :
Our team has been made a stupid thing that affect database in our project. It was happens many times, and we are usually go tinkering or direct edit on a database to fix those problems. The problem is we need to record those change, so we made this package. Besides, we sometime need to doing bulk insert user for our application, so patch will be the best solution.
INSTALLATION
do either of this methods below.
- via shell
composer require jalameta/jps-patcher
- adding
"jalameta/jps-patcher": "^2.0"
tocomposer.json
{ "require": { "jalameta/jps-patcher": "^2.0" } }
POST INSTALLATION
this process is optional, you can skip it though.
-
applying into your project.
-
Laravel >= 5.8
- Automatically loaded :)
-
Laravel <= 5.8
- Add the
\Jalameta\Patcher\PatcherServiceProvider
intoproviders
array inconfig/app.php
- Add the
-
-
patches table creation.
php artisan patcher:install
USAGE
CREATE NEW PATCH
for creating new patch you just need to run these following command
php artisan make:patch what_do_you_want_to_patch
wait, do you feels familiar huh?, we do too. The truth is, this package is extending laravel migration.
after run those command, you will see new file in patches
folder.
Those file will be like:
<?php use Jalameta\Patcher\Patch; class WhatDoYouWantToPatch extends Patch { /** * Run patch script. * * @return void * @throws \Exception */ public function patch() { // } }
Method patch
on these file will be filled with your logic.
in Jalameta\Patcher\Patch
there is some useful properties
that you can use for supporting your patch such as:
-
$container: \Illuminate\Container\Container
-
$command: \Illuminate\Console\Command
we frequently used
$command
property to print process that we're doing. example:$this->command->warn('i patch something danger!'); $this->command->confirm('do you wish to continue?');
you can learn more about
\Illuminate\Console\Command
here. -
$logger: \Illuminate\Log\Logger
$logger
will store log instorage/logs/patches.log
. if you want to change it, add this line below in yourconfig/logging.php
in channels section.[ 'channels' => [ 'patcher' => [ 'driver' => 'patcher', // you can change me if you want 'path' => storage_path('logs/patches.log'), // change me ], ], ];
you can learn more about
\Illuminate\Log\Logger
here
SHOW PATCH STATUS
php artisan patcher:status
Example:
my_project on master [$!] via ⬢ v14.14.0 via 🐘 v7.4.11 on 🐳 v19.03.13 ➜ php artisan patcher:status +------+---------------------------------------+-------+ | Ran? | Patch | Batch | +------+---------------------------------------+-------+ | Yes | 2020_09_29_190531_fix_double_sections | 1 | | Yes | 2020_10_09_124616_add_attachment_beep | 1 | +------+---------------------------------------+-------+
RUN A PATCH(ES)
php artisan patcher:run
Example:
my_project on master [$!] via ⬢ v14.14.0 via 🐘 v7.4.11 on 🐳 v19.03.13
➜ php artisan patcher:status
Patches table created successfully.
Patching: 2020_09_29_190531_fix_double_sections
Patched: 2020_09_29_190531_fix_double_sections (0.03 seconds)
Patching: 2020_10_09_124616_add_attachment_beep
Patched: 2020_10_09_124616_add_attachment_beep (0.06 seconds)