CreateLeaderboardPlayerRewardsTable::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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