<?php

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

class CreatePurchaseRecordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('purchase_records', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('external_sku_id',60)->comment('唯一sku标识');
            $table->string('batch_number',60)->nullable()->comment('批次号');
            $table->date('date')->nullable()->comment('日期');;
            $table->Integer('num')->default(0)->comment('采购数量');
            $table->unsignedDecimal('cost')->default(0)->comment('成本');
            $table->Integer('buyer_user_id')->default(0)->comment('购买人用户id');;
            $table->string('buyer_name')->nullable()->comment('采购人');
            $table->Integer('check_status')->default(0)->comment('盘点完近似状态 0未完成1已售卖完成');
            $table->string('expire_time')->nullable()->comment('保质期时间');
            $table->string('supplier_name')->nullable()->comment('供应商名称');
            $table->Integer('supplier_id')->nullable()->comment('供应商id');
            // 索引
            $table->index('external_sku_id');
            $table->index('created_at');
            $table->index('batch_number');
            $table->timestamps();
        });
    }

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