<?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('doc_type_master', function (Blueprint $table) {

            // Remove old column
            $table->dropColumn('Is_KYC');

            // Add new columns
            $table->enum('Doc_Cat', ['KYC', 'Property', 'Legal', 'Financial', 'Misc'])
                  ->after('DocTy_Name');

            $table->enum('Is_Mandatory', ['YES', 'No'])
                  ->default('YES')
                  ->after('Doc_Cat');

            $table->boolean('Is_Original')
                  ->default(0)
                  ->after('Is_Mandatory');

            $table->boolean('Is_Notarization')
                  ->default(0)
                  ->after('Is_Original');

            $table->boolean('Is_Self_Attested')
                  ->default(1)
                  ->after('Is_Notarization');

            $table->boolean('Is_Govt_verification')
                  ->default(0)
                  ->after('Is_Self_Attested');

            $table->boolean('Is_Validity')
                  ->default(0)
                  ->after('Is_Govt_verification');

            $table->integer('Validity_days')
                  ->nullable()
                  ->after('Is_Validity');

            $table->tinyInteger('Is_Active')
                  ->default(0)
                  ->after('Validity_days');
        });
    }

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

            $table->dropColumn([
                'Doc_Cat',
                'Is_Mandatory',
                'Is_Original',
                'Is_Notarization',
                'Is_Self_Attested',
                'Is_Govt_verification',
                'Is_Validity',
                'Validity_days',
                'Is_Active'
            ]);

            $table->boolean('Is_KYC')->default(0);
        });
    }
};
