<?php

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

class CreateOrderCountingRecordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order_counting_records', function (Blueprint $table) {
            $table->id();
            $table->integer('owner_id')->index()->comment('外键货主');
            $table->integer('shop_id')->nullable()->index()->comment('外键商铺');
            $table->integer('warehouse_id')->nullable()->index()->comment('外键仓库');
            $table->integer('logistic_id')->nullable()->index()->comment('外键快递');
            $table->string('date_target')->index()->comment('该时间为时间, 根据单位扔掉部分信息');
            $table->enum('counting_unit',['日','周','月','年'])->index()->comment('时间粒度');
            $table->integer('amount')->comment('该货主下某天订单总数量');
            $table->timestamps();
        });
    }

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