CreateLeaderboardPlayerRewardsTable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 18 1
A down() 0 3 1
1
<?php
2
3
use Illuminate\Database\Schema\Blueprint;
4
use Illuminate\Database\Migrations\Migration;
5
use Illuminate\Support\Facades\Schema;
6
7
class CreateLeaderboardPlayerRewardsTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('leaderboard_player_rewards', function(Blueprint $table) {
17
            $table->increments('id');
18
19
            $table->integer('leaderboard_timescope_id')->unsigned();
20
            $table->integer('player_id')->unsigned();
21
            $table->integer('score_sum')->unsigned()->nullable();
22
            $table->integer('score_sum_rank')->unsigned()->nullable();
23
            $table->integer('highscore_rank')->unsigned()->nullable();
24
            
25
            $table->timestamps();
26
            
27
            $table->unique(['leaderboard_timescope_id', 'player_id', 'score_sum']);
28
            $table->unique(['leaderboard_timescope_id', 'player_id', 'score_sum_rank']);
29
            $table->unique(['leaderboard_timescope_id', 'player_id', 'highscore_rank']);
30
            $table->foreign('player_id')->references('id')->on('players')->onDelete('cascade');
31
            $table->foreign('leaderboard_timescope_id')->references('id')->on('leaderboard_timescopes')->onDelete('cascade');
32
        });
33
    }
34
35
    /**
36
     * Reverse the migrations.
37
     *
38
     * @return void
39
     */
40
    public function down()
41
    {
42
        Schema::dropIfExists('leaderboard_player_rewards');
43
    }
44
}
45