Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LARAVEL PATCHER
Laravel Patcher
--
*A (migration like) patcher for a smoldering production update.* <br>

Expand All @@ -9,7 +9,7 @@ LARAVEL PATCHER
* PHP : 8.\*
* Laravel: 9.\*

### INSTALLATION
### Installation
do either of this methods below.
* via shell
```shell script
Expand All @@ -23,16 +23,16 @@ composer require dentro/laravel-patcher
}
}
```
### POST INSTALLATION
### Post Installation
> this process is optional, you can skip it though.

patches table creation.
```shell script
php artisan patcher:install
```

### USAGE
#### CREATE NEW PATCH
### Usage
#### Create New Patch
for creating new patch you just need to run these following command
```shell script
php artisan make:patch what_do_you_want_to_patch
Expand Down Expand Up @@ -80,7 +80,7 @@ that you can use for supporting your patch such as:
> ];
> ```
> you can learn more about `\Illuminate\Log\Logger` [here](https://laravel.com/api/8.x/Illuminate/Log/Logger.html)
#### SHOW PATCH STATUS
#### Show Patch Status
```shell script
php artisan patcher:status
```
Expand All @@ -95,7 +95,7 @@ Example:
+------+---------------------------------------+-------+
```

#### RUN A PATCH(ES)
#### Run Pending Patch(es)
```shell script
php artisan patcher:run
```
Expand All @@ -109,7 +109,7 @@ Patching: 2020_10_09_124616_add_attachment_beep
Patched: 2020_10_09_124616_add_attachment_beep (0.06 seconds)
```

#### SKIPPING THE PATCH
#### Conditional Patch
You might need to skip single patch when run ```php artisan patcher:run```.
Due to patch is unnecessary or patch is not eligible to run in your environment.
Here you can add the ```eligible``` method to your patch class to evaluate the condition
Expand Down Expand Up @@ -143,3 +143,14 @@ Skipped: 2020_09_29_190531_fix_double_sections is not eligible to run in curren
Patching: 2020_10_09_124616_add_attachment_beep
Patched: 2020_10_09_124616_add_attachment_beep (0.06 seconds)
```

#### Perpetual Patch
In some cases you might also want to run patches script indefinitely, you can change `isPerpetual`
property on your patch file to `true`

```php
class WhatDoYouWantToPatch extends Patch
{
public bool $isPerpetual = true;
}
```
7 changes: 7 additions & 0 deletions src/Patch.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ abstract class Patch extends Migration
*/
public $withinTransaction = false;

/**
* Determine if patch should run perpetually.
*
* @var bool
*/
public bool $isPerpetual = false;

/**
* Run patch script.
*
Expand Down
6 changes: 4 additions & 2 deletions src/Patcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ protected function patch(string $file, int $batch): void

$runTime = round(microtime(true) - $startTime, 2);

$this->repository->log($name, $batch);
if (! $patch->isPerpetual) {
$this->repository->log($name, $batch);
}

$this->note("<info>Patched:</info> $name ($runTime seconds).");
$this->note("<info>Patched:</info> $name ($runTime seconds)." . $patch->isPerpetual ? " (Perpetual)" : "");
} else {
$this->note("<comment>Skipped:</comment> $name is not eligible to run in current condition.");
}
Expand Down