<?php

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

class CreateGoodsSkuLocationsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable('goods_sku_locations')) {
            return;
        }
        Schema::defaultStringLength(191);
        Schema::create('goods_sku_locations', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->date('date');
            $table->unsignedBigInteger('goods_id');
            $table->unsignedBigInteger('goods_sku_id');
            $table->string('location');
            $table->integer('today_init_num');
            $table->string('external_sku_id');
            $table->string('goods_name')->nullable();
            $table->tinyInteger('status')->default(1);
            $table->string('note')->nullable();
            $table->timestamps();

            $table->unique('external_sku_id', 'location');
        });
    }

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