<?php

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

return new class extends Migration
{

    public function up(): void
    {
        Schema::table('pet_registration', function (Blueprint $table) {


            $table->dropForeign(['CTM_Id']);

            
            $table->dropColumn('CTM_Id');

            $table->unsignedBigInteger('Owner_ID')->nullable()->after('PR_Id');

            $table->foreign('Owner_ID')
                  ->references('Owner_ID')
                  ->on('owner_master')
                  ->onDelete('cascade');
        });
    }


    public function down(): void
    {
        Schema::table('pet_registration', function (Blueprint $table) {


            $table->dropForeign(['Owner_ID']);


            $table->dropColumn('Owner_ID');


            $table->unsignedBigInteger('CTM_Id')->nullable();


            $table->foreign('CTM_Id')
                  ->references('CTM_Id')
                  ->on('ctzn_master')
                  ->onDelete('cascade');
        });
    }
};
