Skip to content

Commit

Permalink
Merge pull request #11668 from bdach/beatmap-versioning
Browse files Browse the repository at this point in the history
Add tables for beatmap versioning support
  • Loading branch information
nanaya authored Nov 20, 2024
2 parents 65ca10d + 48a9101 commit 2ba5952
Showing 1 changed file with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// raw statement used as laravel syntax doesn't support a fixed size BINARY column
DB::statement('CREATE TABLE `beatmapset_files` (
`file_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`sha2_hash` BINARY(32) NOT NULL,
`file_size` INT UNSIGNED NOT NULL,
UNIQUE (`sha2_hash`)
)');

Schema::create('beatmapset_versions', function (Blueprint $table) {
$table->bigIncrements('version_id');
$table->mediumInteger('beatmapset_id')->unsigned();
$table->timestamp('created_at')->useCurrent();
$table->bigInteger('previous_version_id')->unsigned()->nullable();

$table->index('beatmapset_id');
$table->index('previous_version_id');
});

Schema::create('beatmapset_version_files', function (Blueprint $table) {
$table->bigInteger('file_id')->unsigned();
$table->bigInteger('version_id')->unsigned();
$table->string('filename', length: 500);

$table->primary(['file_id', 'version_id']);
$table->index('file_id');
$table->index('version_id');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('beatmapset_version_files');
Schema::dropIfExists('beatmapset_versions');
Schema::dropIfExists('beatmapset_files');
}
};

0 comments on commit 2ba5952

Please sign in to comment.