Skip to content

Commit

Permalink
chore: adjust index names (#1935)
Browse files Browse the repository at this point in the history
  • Loading branch information
luchaos authored Oct 27, 2023
1 parent 22b3049 commit a3b8f27
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
34 changes: 17 additions & 17 deletions database/migrations/2012_10_03_133633_create_base_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function up(): void
} else {
$table->primary(['GameID', 'Address']);
}
$table->index('GameID');
$table->index('GameID', 'memory_notes_game_id_index');
});
}

Expand Down Expand Up @@ -194,7 +194,7 @@ public function up(): void
if (!Schema::hasTable('Forum')) {
Schema::create('Forum', function (Blueprint $table) {
$table->increments('ID');
$table->unsignedInteger('CategoryID')->index();
$table->unsignedInteger('CategoryID')->index('forums_forum_category_id_index');
$table->string('Title', 50);
$table->string('Description', 250);
$table->unsignedInteger('LatestCommentID')->nullable();
Expand Down Expand Up @@ -244,7 +244,7 @@ public function up(): void
if (!Schema::hasTable('ForumTopic')) {
Schema::create('ForumTopic', function (Blueprint $table) {
$table->increments('ID');
$table->unsignedInteger('ForumID')->index();
$table->unsignedInteger('ForumID')->index('forum_topics_forum_id_index');
$table->string('Title');
$table->string('Author', 50);
$table->unsignedInteger('AuthorID');
Expand All @@ -269,11 +269,11 @@ public function up(): void
if (!Schema::hasTable('ForumTopicComment')) {
Schema::create('ForumTopicComment', function (Blueprint $table) {
$table->increments('ID');
$table->unsignedInteger('ForumTopicID')->index();
$table->unsignedInteger('ForumTopicID')->index('forum_topic_comments_forum_topic_id_index');
$table->text('Payload');
$table->string('Author', 50);
$table->unsignedInteger('AuthorID');
$table->timestampTz('DateCreated')->nullable()->index();
$table->timestampTz('DateCreated')->nullable()->index('forum_topic_comments_created_at_index');
$table->timestampTz('DateModified')->nullable()->useCurrent()->useCurrentOnUpdate();
$table->unsignedTinyInteger('Authorised')->nullable();
});
Expand Down Expand Up @@ -333,7 +333,7 @@ public function up(): void
Schema::create('GameData', function (Blueprint $table) {
$table->increments('ID');
$table->string('Title', 80);
$table->unsignedTinyInteger('ConsoleID')->index();
$table->unsignedTinyInteger('ConsoleID')->index('games_system_id_index');
$table->integer('ForumTopicID')->nullable();
$table->integer('Flags')->nullable();
$table->string('ImageIcon', 50)->nullable()->default('/Images/000001.png');
Expand All @@ -348,7 +348,7 @@ public function up(): void
$table->text('RichPresencePatch')->nullable();
$table->unsignedInteger('TotalTruePoints')->default(0);

$table->unique(['Title', 'ConsoleID']);
$table->unique(['Title', 'ConsoleID'], 'games_title_system_id_unique');
});
}

Expand Down Expand Up @@ -411,7 +411,7 @@ public function up(): void
if (!Schema::hasTable('LeaderboardDef')) {
Schema::create('LeaderboardDef', function (Blueprint $table) {
$table->increments('ID');
$table->unsignedInteger('GameID')->default(0)->index();
$table->unsignedInteger('GameID')->default(0)->index('leaderboards_game_id_index');
$table->text('Mem');
$table->string('Format', 50)->nullable()->default('');
$table->string('Title')->default('Leaderboard Title');
Expand Down Expand Up @@ -670,12 +670,12 @@ public function up(): void
$table->unsignedInteger('ReportedByUserID');
$table->unsignedTinyInteger('ReportType');
$table->text('ReportNotes');
$table->timestampTz('ReportedAt')->nullable()->index();
$table->timestampTz('ReportedAt')->nullable()->index('tickets_created_at_index');
$table->timestampTz('ResolvedAt')->nullable();
$table->unsignedInteger('ResolvedByUserID')->nullable();
$table->unsignedTinyInteger('ReportState')->default(1)->comment('1=submitted,2=resolved,3=declined');

$table->unique(['AchievementID', 'ReportedByUserID']);
$table->unique(['AchievementID', 'ReportedByUserID'], 'tickets_achievement_id_reporter_id_unique');
});
}

Expand All @@ -701,7 +701,7 @@ public function up(): void
if (!Schema::hasTable('UserAccounts')) {
Schema::create('UserAccounts', function (Blueprint $table) {
$table->increments('ID'); // NOTE PRIMARY KEY ('ID', 'User') on production
$table->string('User', 32)->unique();
$table->string('User', 32)->unique('users_username_unique');
$table->string('SaltedPass', 32);
$table->string('EmailAddress', 64);
$table->tinyInteger('Permissions')->comment('-2=spam, -1=banned, 0=unconfirmed, 1=confirmed, 2=jr-developer, 3=developer, 4=moderator');
Expand Down Expand Up @@ -730,13 +730,13 @@ public function up(): void
$table->boolean('Untracked')->default(0);
$table->string('email_backup')->nullable();

$table->index(['User', 'Untracked']);
$table->index(['TrueRAPoints', 'Untracked']);
$table->index(['Untracked', 'RAPoints']);
$table->index('LastActivityID');
$table->index(['User', 'Untracked'], 'users_username_untracked_index');
$table->index(['TrueRAPoints', 'Untracked'], 'users_points_weighted_untracked_index');
$table->index(['Untracked', 'RAPoints'], 'users_untracked_points_index');
$table->index('LastActivityID', 'users_last_activity_id_index');

// https://github.com/RetroAchievements/RAWeb/blob/master/database/20200402_230000_Add_UserAccount_Index.sql
$table->index(['RAPoints', 'Untracked']);
$table->index(['RAPoints', 'Untracked'], 'users_points_untracked_index');
});
}

Expand Down Expand Up @@ -782,7 +782,7 @@ public function up(): void
$table->integer('RASoftcorePoints')->nullable()->default(0)->after('RAPoints');

// https://github.com/RetroAchievements/RAWeb/blob/master/database/20220810_000000_Add_UserAccount_SoftcorePoints_Key.sql
$table->index(['RASoftcorePoints', 'Untracked']);
$table->index(['RASoftcorePoints', 'Untracked'], 'users_points_softcore_untracked_index');
});
}

Expand Down
7 changes: 5 additions & 2 deletions docker/mysql/mysql.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ default-character-set = utf8mb4
skip-host-cache
skip-name-resolve

character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

character-set-client-handshake = FALSE
init_connect = "SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci"

0 comments on commit a3b8f27

Please sign in to comment.