<?php

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

class CreateInventoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('inventories', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('owner_id')->index();
            $table->enum('type',['全盘','动盘'])->comment('盘点类型');
            $table->timestamp('start_at')->nullable();
            $table->timestamp('end_at')->nullable();
            $table->integer('total')->nullable()->comment('记录数');
            $table->integer('processed')->default(0)->comment('已盘数');
            $table->integer('difference')->default(0)->comment('复盘差异');
            $table->integer('returned')->default(0)->comment('复盘归位');
            $table->timestamp('deleted_at')->index()->nullable();
            $table->timestamps();
        });
    }

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