Skip to content

Commit e7ace3a

Browse files
committed
Add database table for storing lazer multiplayer room events
The goal of this table is to power display of multiplayer match history for lazer rooms, e.g. #10455. If you squint a bit, you'll notice that the table structure is *extremely* similar to `osu_mp.events`, but to spell things out: - `id` (PK)`: Self-explanatory. - `room_id` (FK referencing `multiplayer_rooms`): Self-explanatory. - `event_type`: Self-explanatory. Uses `string` rather than any explicit `enum` type for more flexibility and to reduce ceremony when adding new types in. - `playlist_item_id` (FK referencing `multiplayer_playlist_items`, optional): Valid if `event_type` is `game_{started,aborted}`. Points at the game in question. - `user_id` (FK referencing `phpbb_users`, optional): If the event can be associated with a user, it will be via this column. - `{created,updated}_at`: Decided to just let laravel generate this one, although osu-web won't really be writing to this table, and I expect 99.999% of records (if not all) to just contain the same value twice here. Not sure. Maybe this can be a single timestamp column or something, please advise. - `event_detail`: This is somewhat new. The goal of this column is to store extra data, in particular in the case of `game_started` events. The specific data I want to store there are: the game mode at the time of starting (be it head-to-head, or team vs, or whichever), and also who's on what team in the room (if team vs). This information is currently not stored anywhere in the database; only the latest game mode is preserved, and the team composition is only stored in memory of the spectator server. This came up recently in ppy/osu#32680 (comment). Potentially, this could also be used to do things like store the users' total scores at the end of the match, which we presumably want to be 'frozen in time' at the point of match completion for archival purposes; because in lazer multiplayer scores just land in the `scores` table and will be treated the same way as solo scores, any potential rebalances could have a side effect of rewriting multiplayer match history if this sort of thing is not done preventatively. (The old `osu_mp` structure is immune from this because it completely mirrors score rows into its `game_scores` table.) Note that currently the assumption is that this table will store events for all rooms going forward, because there is no correspondent of the `osu_mp.matches.keep_forever` flag anywhere for lazer multiplayer rooms. Up for discussion as to whether we want to have one.
1 parent be98854 commit e7ace3a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4+
// See the LICENCE file in the repository root for full licence text.
5+
6+
declare(strict_types=1);
7+
8+
use Illuminate\Database\Migrations\Migration;
9+
use Illuminate\Database\Schema\Blueprint;
10+
use Illuminate\Support\Facades\Schema;
11+
12+
return new class extends Migration
13+
{
14+
/**
15+
* Run the migrations.
16+
*/
17+
public function up(): void
18+
{
19+
Schema::create('multiplayer_realtime_room_events', function (Blueprint $table) {
20+
$table->bigIncrements('id');
21+
$table->unsignedBigInteger('room_id');
22+
$table->string('event_type');
23+
$table->unsignedBigInteger('playlist_item_id')->nullable();
24+
$table->unsignedInteger('user_id')->nullable();
25+
$table->timestamps();
26+
$table->json('event_detail')->nullable();
27+
});
28+
}
29+
30+
/**
31+
* Reverse the migrations.
32+
*/
33+
public function down(): void
34+
{
35+
Schema::dropIfExists('multiplayer_realtime_room_events');
36+
}
37+
};

0 commit comments

Comments
 (0)