<?php

declare(strict_types=1);

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class ExpandCooperativeMembersProgramData extends Migration
{
    public function up(): void
    {
        Schema::table('cooperative_members', function (Blueprint $table) {
            // Priority & classification
            $table->string('priority_sector')->nullable()->after('year_beginning');
            $table->string('common_bond')->nullable()->after('priority_sector'); // Residential/Institutional/Occupational/Associational
            $table->json('vulnerability_classifications')->nullable()->after('common_bond'); // IP, PWD, Senior, Solo Parent, OSY, etc.

            // Government IDs (cooperative context)
            $table->string('philsys_id')->nullable()->after('vulnerability_classifications');
            $table->string('sss_number')->nullable()->after('philsys_id');
            $table->string('pagibig_number')->nullable()->after('sss_number');

            // SLP (Sustainable Livelihood Program)
            $table->string('slp_track')->nullable()->after('pagibig_number'); // MD / EF
            $table->string('slp_association_name')->nullable()->after('slp_track');
            $table->string('listahanan_id')->nullable()->after('slp_association_name');
            $table->string('fourtps_household_id')->nullable()->after('listahanan_id');

            // TUPAD (DOLE)
            $table->string('tupad_category')->nullable()->after('fourtps_household_id'); // Underemployed/Displaced/etc.
            $table->string('tupad_insurance_beneficiary_name')->nullable()->after('tupad_category');
            $table->string('tupad_insurance_beneficiary_relation')->nullable()->after('tupad_insurance_beneficiary_name');

            // OSEC / NSRP Employment
            $table->string('preferred_occupation')->nullable()->after('tupad_insurance_beneficiary_relation');
            $table->json('nsrp_skills')->nullable()->after('preferred_occupation'); // Array of skill strings
            $table->string('employment_status')->nullable()->after('nsrp_skills'); // Employed/Underemployed/Unemployed

            // Program flags
            $table->json('program_participation')->nullable()->after('employment_status'); // ['SLP','TUPAD','OSEC',...]
        });
    }

    public function down(): void
    {
        Schema::table('cooperative_members', function (Blueprint $table) {
            $table->dropColumn([
                'priority_sector', 'common_bond', 'vulnerability_classifications',
                'philsys_id', 'sss_number', 'pagibig_number',
                'slp_track', 'slp_association_name', 'listahanan_id', 'fourtps_household_id',
                'tupad_category', 'tupad_insurance_beneficiary_name', 'tupad_insurance_beneficiary_relation',
                'preferred_occupation', 'nsrp_skills', 'employment_status', 'program_participation',
            ]);
        });
    }
}
