MigrateDbInProduction   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 34
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 2
1
<?php
2
3
namespace Sfneal\Cruise\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Facades\Artisan;
7
use Sfneal\Helpers\Laravel\AppInfo;
8
9
class MigrateDbInProduction extends Command
10
{
11
    public const SUCCESS_MESSAGE = "Running database migrations because the app env is 'production'.";
12
    public const FAILURE_MESSAGE = "Skipped running database migrations because the app env is NOT 'production'.";
13
14
    /**
15
     * The name and signature of the console command.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'migrate:prod';
20
21
    /**
22
     * The console command description.
23
     *
24
     * @var string
25
     */
26
    protected $description = 'Run the database migrations in production';
27
28
    /**
29
     * Execute the console command.
30
     */
31
    public function handle(): int
32
    {
33
        if (AppInfo::isEnvProduction()) {
34
            $this->info("Running database migrations because the app env is 'production'.");
35
            Artisan::call('migrate --force');
36
37
            return self::SUCCESS;
38
        }
39
40
        $this->info("Skipped running database migrations because the app env is NOT 'production'.");
41
42
        return self::FAILURE;
43
    }
44
}
45