<?php

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

class CreateProcurementsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('procurements', function (Blueprint $table) {
            $table->id();
            $table->string('code')->index()->comment('采购编号');
            $table->tinyInteger('type')->index()->default(0)->comment('采购类型');
            $table->bigInteger('owner_material_id')->index()->comment('外键项目耗材');
            $table->bigInteger('supplier_id')->index()->nullable()->comment('外键供应商');
            $table->decimal('quantity')->comment('采购数量');
            $table->decimal('amount')->comment('销售数量');
            $table->decimal('unit_price')->nullable()->comment('销售单价');
            $table->decimal('cost_price')->nullable()->comment('成本单价(采购)');
            $table->tinyInteger('status')->default(0)->comment('状态');//待报价 已报价 待接单 生产中 送货中 已完成 已取消
            $table->enum('is_enquiry',['是','否'])->default('否')->comment('是否询价');
            $table->bigInteger('initiator')->index()->comment('外键用户(发起者)');
            $table->timestamps();
        });
    }

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