2020_12_31_115716_change_log_index_all.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class ChangeLogIndexAll extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::table('logs', function (Blueprint $table) {
  15. $table->index('created_at','index_logs_created_at');
  16. $table->index(['method','created_at'],'index_logs_m_c');
  17. $table->index(['type','created_at'],'index_logs_t_c');
  18. $table->dropIndex('index_logs_c_c');
  19. $table->dropIndex('index_logs_c_t');
  20. });
  21. }
  22. /**
  23. * Reverse the migrations.
  24. *
  25. * @return void
  26. */
  27. public function down()
  28. {
  29. Schema::table('logs', function (Blueprint $table) {
  30. $table->dropIndex('index_logs_created_at');
  31. $table->dropIndex('index_logs_m_c');
  32. $table->dropIndex('index_logs_t_c');
  33. $table->index(['type','created_at'],'index_logs_t_c');
  34. $table->index(['created_at','type'],'index_logs_c_t');
  35. });
  36. }
  37. }