2020_12_31_115716_change_log_index_all.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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->index(['id_user','created_at'],'index_logs_i_c');
  19. // $table->dropIndex('index_logs_i_c');
  20. $table->dropIndex('index_logs_c_c');
  21. $table->dropIndex('index_logs_c_t');
  22. // $table->dropIndex('index_logs_c_m');
  23. });
  24. }
  25. /**
  26. * Reverse the migrations.
  27. *
  28. * @return void
  29. */
  30. public function down()
  31. {
  32. Schema::table('logs', function (Blueprint $table) {
  33. $table->dropIndex('index_logs_created_at');
  34. $table->dropIndex('index_logs_m_c');
  35. $table->dropIndex('index_logs_t_c');
  36. $table->index(['type','created_at'],'index_logs_t_c');
  37. $table->index(['created_at','type'],'index_logs_c_t');
  38. });
  39. }
  40. }