<?php

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

return new class extends Migration
{
     public function up(): void
    {
        // Duplicate table structure
        DB::statement('CREATE TABLE emp_rec_book LIKE emppers_profile');

        // Drop old primary key
        DB::statement('ALTER TABLE emp_rec_book DROP PRIMARY KEY');

        // Rename PK column (change EPP_Id to ERB_Id)
        DB::statement('
            ALTER TABLE emp_rec_book
            CHANGE COLUMN EPP_Id ERB_Id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT
        ');

        // Add new primary key
        DB::statement('ALTER TABLE emp_rec_book ADD PRIMARY KEY (ERB_Id)');
    }

    public function down(): void
    {
        DB::statement('DROP TABLE IF EXISTS emp_rec_book');
    }
};
