<?php

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

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

        Schema::create('exports', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->string('sn', 32)->default('')->comment('命令编号');
            $table->string('tag', 20)->default('')->comment('标记');
            $table->string('disk', 20)->default('')->comment('存储位置');
            $table->string('filename')->default('')->comment('文件名');
            $table->integer('filesize')->unsigned()->default(0)->comment('文件大小');
            $table->text('conditions')->nullable()->comment('查询条件');
            $table->tinyInteger('status')->unsigned()->default(0)->comment('状态 0:数据准备中 1:开始写入 2:写入结束 3:保存成功 4:任务失败');
            $table->tinyInteger('progress')->unsigned()->default(0)->comment('进度');
            $table->timestamps();
            $table->unique('sn');
            $table->index('tag');
            $table->comment('VD统计导出表');
        });
    }

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