-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11668 from bdach/beatmap-versioning
Add tables for beatmap versioning support
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
database/migrations/2024_11_19_130731_create_beatmap_versioning_tables.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
}; |