Completed
Push — master ( 2f5a59...1aef96 )
by Julien
10:27 queued 03:33
created

CreateLtFightTable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 56
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B up() 0 36 2
A down() 0 6 1
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
use Xoco70\LaravelTournaments\DBHelpers;
7
8
class CreateLtFightTable extends Migration
9
{
10
    /**
11
     * Run the migrations.
12
     *
13
     * @return void
14
     */
15
    public function up()
16
    {
17
        if (!Schema::hasTable('fight')) {
18
            Schema::create('fight', function (Blueprint $table) {
19
                $table->increments('id');
20
                $table->integer('short_id')->unsigned()->nullable();
21
                $table->integer('fighters_group_id')->unsigned()->index();
22
                $table->foreign('fighters_group_id')
23
                    ->references('id')
24
                    ->on('fighters_groups')
25
                    ->onUpdate('cascade')
26
                    ->onDelete('cascade');
27
                $table->integer('c1')->nullable()->unsigned()->index();
28
                $table->integer('c2')->nullable()->unsigned()->index();
29
                $table->char('point1_c1')->nullable();
30
                $table->char('point2_c1')->nullable();
31
                $table->char('point1_c2')->nullable();
32
                $table->char('point2_c2')->nullable();
33
                $table->integer('winner_id')->unsigned()->nullable();
34
35
                $table->boolean('hansoku1_c1')->nullable();
36
                $table->boolean('hansoku2_c1')->nullable();
37
                $table->boolean('hansoku3_c1')->nullable();
38
                $table->boolean('hansoku4_c1')->nullable();
39
                $table->boolean('hansoku1_c2')->nullable();
40
                $table->boolean('hansoku2_c2')->nullable();
41
                $table->boolean('hansoku3_c2')->nullable();
42
                $table->boolean('hansoku4_c2')->nullable();
43
44
                $table->tinyInteger('area')->default(1);
45
                $table->tinyInteger('order')->default(1);
46
                $table->timestamps();
47
                $table->engine = 'InnoDB';
48
            });
49
        }
50
    }
51
52
    /**
53
     * Reverse the migrations.
54
     *
55
     * @return void
56
     */
57
    public function down()
58
    {
59
        DBHelpers::setFKCheckOff();
60
        Schema::dropIfExists('fight');
61
        DBHelpers::setFKCheckOn();
62
    }
63
}
64