2019_02_13_221138_add_soft_delete_indexes.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class AddSoftDeleteIndexes extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::table('avatars', function (Blueprint $table) {
  15. $table->index('deleted_at','avatars_deleted_at_index');
  16. });
  17. Schema::table('profiles', function (Blueprint $table) {
  18. $table->index('deleted_at','profiles_deleted_at_index');
  19. });
  20. Schema::table('mentions', function (Blueprint $table) {
  21. $table->index('deleted_at','mentions_deleted_at_index');
  22. });
  23. Schema::table('likes', function (Blueprint $table) {
  24. $table->index('deleted_at','likes_deleted_at_index');
  25. });
  26. Schema::table('statuses', function (Blueprint $table) {
  27. $table->index('deleted_at','statuses_deleted_at_index');
  28. });
  29. Schema::table('media', function (Blueprint $table) {
  30. $table->index('deleted_at','media_deleted_at_index');
  31. });
  32. Schema::table('notifications', function (Blueprint $table) {
  33. $table->index('deleted_at','notifications_deleted_at_index');
  34. });
  35. Schema::table('users', function (Blueprint $table) {
  36. $table->index('deleted_at','users_deleted_at_index');
  37. });
  38. }
  39. /**
  40. * Reverse the migrations.
  41. *
  42. * @return void
  43. */
  44. public function down()
  45. {
  46. Schema::table('avatars', function (Blueprint $table) {
  47. $table->dropIndex('avatars_deleted_at_index');
  48. });
  49. Schema::table('profiles', function (Blueprint $table) {
  50. $table->dropIndex('profiles_deleted_at_index');
  51. });
  52. Schema::table('mentions', function (Blueprint $table) {
  53. $table->dropIndex('mentions_deleted_at_index');
  54. });
  55. Schema::table('likes', function (Blueprint $table) {
  56. $table->dropIndex('likes_deleted_at_index');
  57. });
  58. Schema::table('statuses', function (Blueprint $table) {
  59. $table->dropIndex('statuses_deleted_at_index');
  60. });
  61. Schema::table('media', function (Blueprint $table) {
  62. $table->dropIndex('media_deleted_at_index');
  63. });
  64. Schema::table('notifications', function (Blueprint $table) {
  65. $table->dropIndex('notifications_deleted_at_index');
  66. });
  67. Schema::table('users', function (Blueprint $table) {
  68. $table->dropIndex('users_deleted_at_index');
  69. });
  70. }
  71. }