<?php

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

class AddOrderTotalAmountToDailyStockRecord extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasColumns('daily_stock_records', ['order_total_amount',"batch_number"])) {
            return;
        }
        Schema::table('daily_stock_records', function (Blueprint $table) {
            $table->decimal('order_total_amount')->default(0)->comment('订单总金额');
            $table->string('batch_number',60)->nullable()->comment('批次号');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (Schema::hasColumns('daily_stock_records', ['order_total_amount',"batch_number"])) {
            return;
        }
        Schema::table('daily_stock_records', function (Blueprint $table) {
            //
            $table->dropColumn('order_total_amount');
            $table->dropColumn('batch_number');
        });
    }
}
