Passed
Push — master ( 0a2dad...a9b714 )
by Anton
04:22 queued 01:15
created

CreateLoveReactantReactionTotalsTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 13
c 2
b 0
f 0
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A 2018_07_25_001000_create_love_reactant_reaction_totals_table.php$0 ➔ down() 0 3 1
A 2018_07_25_001000_create_love_reactant_reaction_totals_table.php$0 ➔ up() 0 14 1
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
use Cog\Laravel\Love\Reactant\ReactionTotal\Models\ReactionTotal;
15
use Cog\Laravel\Love\Support\Database\Migration;
16
use Illuminate\Database\Schema\Blueprint;
17
18
return new class extends Migration
19
{
20
    /**
21
     * Run the migrations.
22
     */
23
    public function up(): void
24
    {
25
        $this->schema->create((new ReactionTotal())->getTable(), function (Blueprint $table) {
26
            $table->bigIncrements('id');
27
            $table->unsignedBigInteger('reactant_id');
28
            $table->unsignedBigInteger('count');
29
            $table->decimal('weight', 13, 2);
30
            $table->timestamps();
31
32
            $table
33
                ->foreign('reactant_id')
34
                ->references('id')
35
                ->on('love_reactants')
36
                ->onDelete('cascade');
37
        });
38
    }
39
40
    /**
41
     * Reverse the migrations.
42
     */
43
    public function down(): void
44
    {
45
        $this->schema->dropIfExists((new ReactionTotal())->getTable());
46
    }
47
};
48