| Total Complexity | 2 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class CreateLeaderboardScoresTable extends Migration |
||
| 8 | { |
||
| 9 | |||
| 10 | /** |
||
| 11 | * Run the migrations. |
||
| 12 | * |
||
| 13 | * @return void |
||
| 14 | */ |
||
| 15 | public function up() |
||
| 16 | { |
||
| 17 | Schema::create('leaderboard_scores', function(Blueprint $table) { |
||
| 18 | $table->increments('id'); |
||
| 19 | |||
| 20 | $table->integer('leaderboard_timescope_id')->unsigned(); |
||
| 21 | $table->integer('player_id')->unsigned(); |
||
| 22 | $table->integer('score_sum')->unsigned()->default('0'); |
||
| 23 | $table->integer('highscore')->unsigned()->default('0'); |
||
| 24 | |||
| 25 | $table->timestamps(); |
||
| 26 | |||
| 27 | $table->index(['leaderboard_timescope_id', 'player_id']); // To find a player's score directly |
||
| 28 | $table->index(['leaderboard_timescope_id', 'score_sum']); // To show score-sum leaderboard |
||
| 29 | $table->index(['leaderboard_timescope_id', 'highscore']); // To show highscore leaderboard |
||
| 30 | $table->foreign('leaderboard_timescope_id')->references('id')->on('leaderboard_timescopes')->onDelete('cascade'); |
||
| 31 | }); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Reverse the migrations. |
||
| 36 | * |
||
| 37 | * @return void |
||
| 38 | */ |
||
| 39 | public function down() |
||
| 42 | } |
||
| 43 | |||
| 44 | } |