<?php

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

class CreateTracesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('traces', function (Blueprint $table) {
            $table->increments('id');

            $table->string('key')->comment('单元识别码');
            $table->string('group')->nullable()->comment('分组标记');
            $table->integer('gid')->default(0)->comment('物品id');
            $table->timestamp('look_time')->nullable()->comment('查看时间');
            $table->integer('look_count')->default(0)->comment('查看的次数');
            $table->integer('dealer_id')->default(0)->comment('经销商id');
            $table->integer('product_id')->default(0)->comment('产品id');
            $table->text('remark')->nullable()->comment('备注');
            $table->string('slug')->nullable()->comment('key');
            $table->tinyInteger('status')->default(1)->comment('状态');

            $table->timestamps();

            $table->unique('key');
        });
    }

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