CreateLeaderboardRewardsTable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 19 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 CreateLeaderboardRewardsTable extends Migration
8
{
9
10
    /**
11
     * Run the migrations.
12
     *
13
     * @return void
14
     */
15
    public function up()
16
    {
17
        Schema::create('leaderboard_rewards', function(Blueprint $table) {
18
            $table->increments('id');
19
20
            $table->integer('leaderboard_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
            $table->tinyInteger('type')->unsigned()->default('1');
25
            $table->integer('amount')->unsigned()->default('1');
26
            $table->integer('item_id')->unsigned()->nullable();
27
28
            $table->timestamps();
29
30
            $table->index(['leaderboard_id', 'score_sum']);
31
            $table->index(['leaderboard_id', 'score_sum_rank']);
32
            $table->index(['leaderboard_id', 'highscore_rank']);
33
            $table->foreign('leaderboard_id')->references('id')->on('leaderboards')->onDelete('cascade');
34
        });
35
    }
36
37
    /**
38
     * Reverse the migrations.
39
     *
40
     * @return void
41
     */
42
    public function down()
43
    {
44
        Schema::dropIfExists('leaderboard_rewards');
45
    }
46
47
}