<?php

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

class AddColumnDiscountDate extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('owner_price_operations', function (Blueprint $table) {
            $table->date("discount_date")->nullable()->comment("满减标记日");
            $table->decimal("total_price")->nullable()->comment("按单计价");
            $table->decimal("total_discount_price")->nullable()->comment("减免总价");
        });
        Schema::table('owner_fee_details', function (Blueprint $table) {
            $table->bigInteger("owner_price_operation_id")->nullable()->comment("引用的计费模型");
            $table->dropIndex(["worked_at"]);
            $table->index(["worked_at","owner_price_operation_id"]);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('owner_price_operations', function (Blueprint $table) {
            $table->dropColumn("discount_date");
            $table->dropColumn("total_price");
            $table->dropColumn("total_discount_price");
        });
        Schema::table('owner_fee_details', function (Blueprint $table) {
            $table->dropColumn("owner_price_operation_id");
            $table->dropIndex([["worked_at","owner_price_operation_id"]]);
            $table->index(["worked_at"]);
        });
    }
}
