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

CreateLtFightersGroupCompetitorTable::up()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 18

Duplication

Lines 24
Ratio 100 %

Importance

Changes 0
Metric Value
dl 24
loc 24
rs 8.9713
c 0
b 0
f 0
cc 1
eloc 18
nc 1
nop 0
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 View Code Duplication
class CreateLtFightersGroupCompetitorTable extends Migration
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * Run the migrations.
12
     *
13
     * @return void
14
     */
15
    public function up()
16
    {
17
        Schema::create('fighters_group_competitor', function (Blueprint $table) {
18
            $table->increments('id');
19
            $table->integer('competitor_id')->unsigned()->nullable()->index();
20
            $table->integer('fighters_group_id')->unsigned()->index();
21
            $table->integer('order')->unsigned()->nullable();
22
            $table->timestamps();
23
24
            $table->foreign('competitor_id')
25
                ->references('id')
26
                ->on('competitor')
27
                ->onUpdate('cascade')
28
                ->onDelete('cascade');
29
30
            $table->foreign('fighters_group_id')
31
                ->references('id')
32
                ->on('fighters_groups')
33
                ->onUpdate('cascade')
34
                ->onDelete('cascade');
35
36
            $table->unique(['competitor_id', 'fighters_group_id']);
37
        });
38
    }
39
40
    /**
41
     * Reverse the migrations.
42
     *
43
     * @return void
44
     */
45
    public function down()
46
    {
47
        DBHelpers::setFKCheckOff();
48
        Schema::dropIfExists('fighters_group_competitor');
49
        DBHelpers::setFKCheckOn();
50
    }
51
}
52