-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into private-staging
- Loading branch information
Showing
17 changed files
with
142 additions
and
74 deletions.
There are no files selected for viewing
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
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
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
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
69 changes: 69 additions & 0 deletions
69
database/migrations/2023_12_18_085034_update_scores_table.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,69 @@ | ||
<?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. | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
private static function resetView(): void | ||
{ | ||
DB::statement('DROP VIEW scores'); | ||
DB::statement('CREATE VIEW scores AS SELECT * FROM solo_scores'); | ||
} | ||
|
||
public function up(): void | ||
{ | ||
Schema::table('solo_scores', function (Blueprint $table) { | ||
$table->dropColumn('updated_at'); | ||
|
||
$table->dropIndex('solo_scores_beatmap_id_index'); | ||
$table->dropIndex('solo_scores_preserve_index'); | ||
$table->dropIndex('user_ruleset_id_index'); | ||
|
||
$table->boolean('ranked')->default(true)->after('preserve'); | ||
$table->unsignedInteger('unix_updated_at')->default(DB::raw('(unix_timestamp())')); | ||
$table->timestamp('created_at')->useCurrent()->change(); | ||
|
||
$table->index(['user_id', 'ruleset_id'], 'user_ruleset_index'); | ||
$table->index(['beatmap_id', 'user_id'], 'beatmap_user_index'); | ||
}); | ||
|
||
DB::statement('ALTER TABLE solo_scores MODIFY id bigint unsigned NOT NULL'); | ||
DB::statement('ALTER TABLE solo_scores DROP PRIMARY KEY'); | ||
DB::statement('ALTER TABLE solo_scores ADD PRIMARY KEY (id, preserve, unix_updated_at)'); | ||
DB::statement('ALTER TABLE solo_scores MODIFY id bigint unsigned NOT NULL AUTO_INCREMENT'); | ||
|
||
static::resetView(); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::table('solo_scores', function (Blueprint $table) { | ||
$table->dropColumn('unix_updated_at'); | ||
$table->dropColumn('ranked'); | ||
|
||
$table->dropIndex('user_ruleset_index'); | ||
$table->dropIndex('beatmap_user_index'); | ||
|
||
$table->datetime('created_at')->change(); | ||
$table->timestamp('updated_at')->nullable(true); | ||
|
||
$table->index('preserve', 'solo_scores_preserve_index'); | ||
$table->index('beatmap_id', 'solo_scores_beatmap_id_index'); | ||
$table->index(['user_id', 'ruleset_id', DB::raw('id DESC')], 'user_ruleset_id_index'); | ||
}); | ||
|
||
DB::statement('ALTER TABLE solo_scores MODIFY id bigint unsigned NOT NULL'); | ||
DB::statement('ALTER TABLE solo_scores DROP PRIMARY KEY'); | ||
DB::statement('ALTER TABLE solo_scores ADD PRIMARY KEY (id)'); | ||
DB::statement('ALTER TABLE solo_scores MODIFY id bigint unsigned NOT NULL AUTO_INCREMENT'); | ||
|
||
static::resetView(); | ||
} | ||
}; |
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
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
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
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
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
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
Oops, something went wrong.