<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLogs extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable('logs')) {
            return;
        }

        Schema::create('logs', function (Blueprint $table) {
            $table->bigInteger('id')->unsigned()->default(0)->comment('日志ID');
            $table->string('request_url', 255)->default('')->comment('请求地址');
            $table->string('request_method', 10)->default('')->comment('请求方法');
            $table->text('request_param')->nullbale('')->comment('请求参数');
            $table->string('request_device')->default('')->comment('请求设备');
            $table->string('request_browser')->default('')->comment('请求浏览器');
            $table->string('request_languages')->default('')->comment('语言');
            $table->mediumInteger('response_status')->unsigned()->default(200)->comment('返回状态码');
            $table->text('response_content')->nullbale()->comment('返回内容');
            $table->string('action', 32)->default('')->comment('动作');
            $table->string('ip', 15)->default('')->comment('操作IP');
            $table->bigInteger('creator_id')->unsigned()->default(0)->comment('操作者ID');
            $table->string('creator_type', 10)->default('')->comment('操作者类型');
            $table->string('creator_username', 32)->default('')->comment('操作者名称');
            $table->string('creator_nickname', 32)->default('')->comment('操作者昵称');
            $table->integer('microtime')->unsigned()->default(0)->comment('请求时间');
            $table->timestamps();

            $table->primary('id');

            $table->comment('日志表');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('logs');
    }
}
