2019_02_13_195702_add_indexes.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class AddIndexes extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::table('statuses', function (Blueprint $table) {
  15. $table->index('visibility','statuses_visibility_index');
  16. $table->index(['in_reply_to_id', 'reblog_of_id'], 'statuses_in_reply_or_reblog_index');
  17. $table->index('uri', 'statuses_uri_index');
  18. $table->index('is_nsfw', 'statuses_is_nsfw_index');
  19. $table->index('created_at', 'statuses_created_at_index');
  20. $table->index('profile_id', 'statuses_profile_id_index');
  21. $table->index('local', 'statuses_local_index');
  22. });
  23. Schema::table('notifications', function (Blueprint $table) {
  24. $table->index('created_at','notifications_created_at_index');
  25. $table->index('actor_id', 'notifications_actor_id_index');
  26. });
  27. Schema::table('profiles', function (Blueprint $table) {
  28. $table->index('domain', 'profiles_domain_index');
  29. });
  30. Schema::table('media', function (Blueprint $table) {
  31. $table->index('user_id', 'media_user_id_index');
  32. });
  33. Schema::table('likes', function (Blueprint $table) {
  34. $table->index('created_at', 'likes_created_at_index');
  35. });
  36. Schema::table('followers', function (Blueprint $table) {
  37. $table->index('created_at', 'followers_created_at_index');
  38. });
  39. }
  40. /**
  41. * Reverse the migrations.
  42. *
  43. * @return void
  44. */
  45. public function down()
  46. {
  47. Schema::table('statuses', function (Blueprint $table) {
  48. $table->dropIndex('statuses_visibility_index');
  49. $table->dropIndex('statuses_in_reply_or_reblog_index');
  50. $table->dropIndex('statuses_uri_index');
  51. $table->dropIndex('statuses_is_nsfw_index');
  52. $table->dropIndex('statuses_created_at_index');
  53. $table->dropIndex('statuses_profile_id_index');
  54. $table->dropIndex('statuses_local_index');
  55. });
  56. Schema::table('notifications', function (Blueprint $table) {
  57. $table->dropIndex('notifications_created_at_index');
  58. $table->dropIndex('notifications_actor_id_index');
  59. });
  60. Schema::table('profiles', function (Blueprint $table) {
  61. $table->dropIndex('profiles_domain_index');
  62. });
  63. Schema::table('media', function (Blueprint $table) {
  64. $table->dropIndex('media_user_id_index');
  65. });
  66. Schema::table('likes', function (Blueprint $table) {
  67. $table->dropIndex('likes_created_at_index');
  68. });
  69. Schema::table('followers', function (Blueprint $table) {
  70. $table->dropIndex('followers_created_at_index');
  71. });
  72. }
  73. }