Completed
Pull Request — master (#88)
by Anton
02:48
created

UpgradeV7ToV8::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of Laravel Love.
5
 *
6
 * (c) Anton Komarev <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Cog\Laravel\Love\Console\Commands;
15
16
use Illuminate\Console\Command;
17
use Illuminate\Database\Schema\Blueprint;
18
use Illuminate\Database\Schema\Builder;
19
use Illuminate\Support\Facades\Config;
20
use Illuminate\Support\Facades\Schema;
21
22
final class UpgradeV7ToV8 extends Command
23
{
24
    /**
25
     * The name and signature of the console command.
26
     *
27
     * @var string
28
     */
29
    protected $signature = 'love:upgrade-v7-to-v8';
30
31
    /**
32
     * The console command description.
33
     *
34
     * @var string
35
     */
36
    protected $description = 'Upgrade love package from v7 to v8';
37
38
    /**
39
     * Execute the console command.
40
     *
41
     * @return void
42
     */
43
    public function handle(): void
44
    {
45
        $this->dbChangeReactionType();
46
    }
47
48
    private function dbChangeReactionType(): void
49
    {
50
        $this->getDbSchema()->table('reaction_types', function (Blueprint $table) {
51
            $table->renameColumn('weight', 'mass');
52
        });
53
    }
54
55
    private function getDbSchema(): Builder
56
    {
57
        return Schema::connection(Config::get('love.storage.database.connection'));
58
    }
59
}
60