<?php

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

class UpdateNullableDefaultsInInvoicesTable extends Migration
{
    public function up()
    {
        Schema::table('invoices', function (Blueprint $table) {
            $table->decimal('subtotal', 12, 2)->nullable()->default(0)->change();
            $table->decimal('discount', 12, 2)->nullable()->default(0)->change();
            $table->decimal('taxable_total', 12, 2)->nullable()->default(0)->change();
            $table->decimal('tax_total', 12, 2)->nullable()->default(0)->change();
        });
    }

    public function down()
    {
        Schema::table('invoices', function (Blueprint $table) {
            $table->decimal('subtotal', 12, 2)->nullable(false)->default(null)->change();
            $table->decimal('discount', 12, 2)->nullable(false)->default(0)->change();
            $table->decimal('taxable_total', 12, 2)->nullable(false)->default(null)->change();
            $table->decimal('tax_total', 12, 2)->nullable(false)->default(null)->change();
        });
    }
}

