<?php

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

class ChangeOwnerBillReportsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        \App\Authority::query()->firstOrCreate(["name"=>"结算管理-即时账单-重置即时账单"],[
            "name"=>"结算管理-即时账单-重置即时账单",
            "alias_name"=>"结算管理-即时账单-重置即时账单"
        ]);
        \App\Authority::query()->firstOrCreate(["name"=>"结算管理-账单确认-重置账单确认"],[
            "name"=>"结算管理-账单确认-重置账单确认",
            "alias_name"=>"结算管理-账单确认-重置账单确认"
        ]);
        Schema::table('owner_bill_reports', function (Blueprint $table) {
            $table->decimal('initial_fee',11,3)->nullable()->comment('原始账单金额')->change();
            $table->decimal('confirm_fee',11,3)->nullable()->comment('确认账单金额')->change();
            $table->decimal('difference',11,3)->nullable()->comment('差额')->change();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        \App\Authority::query()->whereIn("name",["结算管理-账单确认-重置账单确认","结算管理-账单确认-重置账单确认"])->delete();
        Schema::table('owner_bill_reports', function (Blueprint $table) {
            $table->decimal('initial_fee',8,4)->nullable()->comment('原始账单金额')->change();
            $table->decimal('confirm_fee',8,4)->nullable()->comment('确认账单金额')->change();
            $table->decimal('difference',8,4)->nullable()->comment('差额')->change();
        });
    }
}
