Code Duplication    Length = 34-45 lines in 3 locations

database/migrations/2016_95_04_171759_create_Team_table.php 1 location

@@ 6-39 (lines=34) @@
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
6
class CreateTeamTable extends Migration
7
{
8
9
    public function up()
10
    {
11
        Schema::create('team', function (Blueprint $table) {
12
            $table->increments('id');
13
            $table->string('name');
14
            $table->integer('championship_id')->unsigned()->index(); // A checar
15
            $table->string('picture')->nullable();
16
            $table->string('entity_type')->nullable(); // Club, Assoc, Fed
17
            $table->integer('entity_id')->unsigned()->nullable()->index();
18
            $table->timestamps();
19
20
21
            $table->foreign('championship_id')
22
                ->references('id')
23
                ->on('championship')
24
                ->onUpdate('cascade')
25
                ->onDelete('cascade');
26
27
            $table->unique(['championship_id', 'name']);
28
        });
29
    }
30
31
    public function down()
32
    {
33
34
        DB::statement('SET FOREIGN_KEY_CHECKS = 0');
35
        Schema::drop('team');
36
        DB::statement('SET FOREIGN_KEY_CHECKS = 1');
37
38
    }
39
}

database/migrations/2017_02_12_000428_create_Round_Competitor_table.php 1 location

@@ 7-51 (lines=45) @@
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreateRoundCompetitorTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('competitor_round', function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->integer('competitor_id')->unsigned()->index();
19
            $table->integer('round_id')->unsigned()->index(); // A checar
20
            $table->timestamps();
21
22
23
            $table->foreign('competitor_id')
24
                ->references('id')
25
                ->on('competitor')
26
                ->onUpdate('cascade')
27
                ->onDelete('cascade');
28
29
            $table->foreign('round_id')
30
                ->references('id')
31
                ->on('round')
32
                ->onUpdate('cascade')
33
                ->onDelete('cascade');
34
35
            $table->unique(['competitor_id', 'round_id']);
36
        });
37
    }
38
39
    /**
40
     * Reverse the migrations.
41
     *
42
     * @return void
43
     */
44
    public function down()
45
    {
46
        DB::statement('SET FOREIGN_KEY_CHECKS = 0');
47
        Schema::dropIfExists('competitor_round');
48
        DB::statement('SET FOREIGN_KEY_CHECKS = 1');
49
50
    }
51
}
52

database/migrations/2017_02_12_000437_create_Round_Team_table.php 1 location

@@ 7-51 (lines=45) @@
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreateRoundTeamTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('team_round', function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->integer('team_id')->unsigned()->index();
19
            $table->integer('round_id')->unsigned()->index(); // A checar
20
            $table->timestamps();
21
22
23
            $table->foreign('team_id')
24
                ->references('id')
25
                ->on('team')
26
                ->onUpdate('cascade')
27
                ->onDelete('cascade');
28
29
            $table->foreign('round_id')
30
                ->references('id')
31
                ->on('round')
32
                ->onUpdate('cascade')
33
                ->onDelete('cascade');
34
35
            $table->unique(['team_id', 'round_id']);
36
        });
37
    }
38
39
    /**
40
     * Reverse the migrations.
41
     *
42
     * @return void
43
     */
44
    public function down()
45
    {
46
        DB::statement('SET FOREIGN_KEY_CHECKS = 0');
47
        Schema::dropIfExists('team_round');
48
        DB::statement('SET FOREIGN_KEY_CHECKS = 1');
49
50
    }
51
}
52