From e15d0ea891c79f7c2b15c47c1431297c10a548a4 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 13 Feb 2019 13:23:26 -0700 Subject: [PATCH] Add indexes, closes #831 --- .../2019_02_13_195702_add_indexes.php | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 database/migrations/2019_02_13_195702_add_indexes.php diff --git a/database/migrations/2019_02_13_195702_add_indexes.php b/database/migrations/2019_02_13_195702_add_indexes.php new file mode 100644 index 000000000..e52c13cf3 --- /dev/null +++ b/database/migrations/2019_02_13_195702_add_indexes.php @@ -0,0 +1,86 @@ +index('visibility','statuses_visibility_index'); + $table->index(['in_reply_to_id', 'reblog_of_id'], 'statuses_in_reply_or_reblog_index'); + $table->index('uri', 'statuses_uri_index'); + $table->index('is_nsfw', 'statuses_is_nsfw_index'); + $table->index('created_at', 'statuses_created_at_index'); + $table->index('profile_id', 'statuses_profile_id_index'); + $table->index('local', 'statuses_local_index'); + }); + + Schema::table('notifications', function (Blueprint $table) { + $table->index('created_at','notifications_created_at_index'); + $table->index('actor_id', 'notifications_actor_id_index'); + }); + + Schema::table('profiles', function (Blueprint $table) { + $table->index('domain', 'profiles_domain_index'); + }); + + Schema::table('media', function (Blueprint $table) { + $table->index('user_id', 'media_user_id_index'); + }); + + Schema::table('likes', function (Blueprint $table) { + $table->index('created_at', 'likes_created_at_index'); + }); + + Schema::table('followers', function (Blueprint $table) { + $table->index('created_at', 'followers_created_at_index'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('statuses', function (Blueprint $table) { + $table->dropIndex('statuses_visibility_index'); + $table->dropIndex('statuses_in_reply_or_reblog_index'); + $table->dropIndex('statuses_uri_index'); + $table->dropIndex('statuses_is_nsfw_index'); + $table->dropIndex('statuses_created_at_index'); + $table->dropIndex('statuses_profile_id_index'); + $table->dropIndex('statuses_local_index'); + }); + + Schema::table('notifications', function (Blueprint $table) { + $table->dropIndex('notifications_created_at_index'); + $table->dropIndex('notifications_actor_id_index'); + }); + + Schema::table('profiles', function (Blueprint $table) { + $table->dropIndex('profiles_domain_index'); + }); + + Schema::table('media', function (Blueprint $table) { + $table->dropIndex('media_user_id_index'); + }); + + Schema::table('likes', function (Blueprint $table) { + $table->dropIndex('likes_created_at_index'); + }); + + Schema::table('followers', function (Blueprint $table) { + $table->dropIndex('followers_created_at_index'); + }); + } +}