PHP code example of mll-lab / laravel-conditional-migrations
1. Go to this page and download the library: Download mll-lab/laravel-conditional-migrations library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mll-lab / laravel-conditional-migrations example snippets
use MLL\ConditionalMigrations\Contracts\ConditionalMigration;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Carbon;
class DoSomethingVeryIntensive extends Migration implements ConditionalMigration
{
public function up() { ... }
public function down() { ... }
public function shouldRun(): bool
{
return (new Carbon('1 AM'))->lessThan(now())
&& (new Carbon('2 AM'))->greaterThan(now());
}
}
'always_run' => env('APP_DEBUG', false),
'always_run' => function (): bool {
// calculate if migrations should always run
},