<?php

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

class CreatePetCertificatesTable extends Migration
{
    public function up()
    {
        Schema::create('pet_certificates', function (Blueprint $table) {
            $table->bigIncrements('PC_Id');

            $table->integer('Reference_Id')->nullable();

            $table->unsignedBigInteger('PR_Id');
            $table->unsignedBigInteger('CM_Id');

            $table->string('Certificate_No', 50)->nullable();
            $table->date('Issue_Date')->nullable();
            $table->date('Expiry_Date')->nullable();

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

            // Foreign Keys
            $table->foreign('PR_Id')->references('PR_Id')->on('pet_registration')->onDelete('cascade');
            $table->foreign('CM_Id')->references('CM_Id')->on('certificate_master')->onDelete('cascade');
        });
    }

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