2020_08_21_145711_create_rule_log_table.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateRuleLogTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('rule_log', function (Blueprint $table) {
  15. $table->increments('id');
  16. $table->unsignedInteger('user_id')->default(0)->comment('用户ID');
  17. $table->unsignedInteger('node_id')->default(0)->comment('节点ID');
  18. $table->unsignedInteger('rule_id')->default(0)->comment('规则ID,0表示白名单模式下访问访问了非规则允许的网址');
  19. $table->string('reason')->nullable()->comment('触发原因');
  20. $table->dateTime('created_at')->comment('创建时间');
  21. $table->index(['user_id', 'node_id', 'rule_id'], 'idx');
  22. });
  23. }
  24. /**
  25. * Reverse the migrations.
  26. *
  27. * @return void
  28. */
  29. public function down()
  30. {
  31. Schema::dropIfExists('rule_log');
  32. }
  33. }