<?php

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

class CreateTaMaRateMasterTable extends Migration
{
    public function up()
    {
        Schema::create('ta_ma_rate_master', function (Blueprint $table) {
            $table->bigIncrements('ta_ma_rate_id');

            $table->unsignedBigInteger('EGM_Id');
            $table->unsignedBigInteger('CGR_Id');

            $table->decimal('TA', 15, 2)->default(0);
            $table->decimal('MA', 15, 2)->default(0);

            $table->timestamps();
            $table->softDeletes(); // deleted_at

            // FK with RESTRICT delete
            $table->foreign('EGM_Id')
                  ->references('EGM_Id')
                  ->on('emp_grade_master')
                  ->onDelete('restrict');

            $table->foreign('CGR_Id')
                  ->references('CGR_Id')
                  ->on('city_grade')
                  ->onDelete('restrict');
        });
    }

    public function down()
    {
        Schema::dropIfExists('ta_ma_rate_master');
    }
}
