CreateCountersTables   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
eloc 18
c 2
b 1
f 0
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 20 1
A down() 0 4 1
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreateCountersTables extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
17
        Schema::create('counters', function (Blueprint $table) {
18
            $table->id();
19
            $table->string('key')->unique();
20
            $table->string('name');
21
            $table->double('initial_value')->default('0');
22
            $table->double('value')->default('0');
23
            $table->double('step')->default('1');
24
            $table->text('notes')->nullable();
25
            $table->timestamps();
26
        });
27
28
        Schema::create('counterables', function (Blueprint $table) {
29
            $table->id();
30
            $table->morphs('counterable');
31
            $table->unsignedBigInteger('counter_id');
32
            $table->double('value')->default('0');
33
            $table->timestamps();
34
        });
35
    }
36
37
    /**
38
     * Reverse the migrations.
39
     *
40
     * @return void
41
     */
42
    public function down()
43
    {
44
        Schema::dropIfExists('counterables');
45
        Schema::dropIfExists('counters');
46
    }
47
}
48