<?php

declare(strict_types=1);

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

class CreateBarangayProjectsTable extends Migration
{
    public function up(): void
    {
        Schema::create('barangay_projects', function (Blueprint $table) {
            $table->id();
            $table->string('hashkey')->unique()->nullable();
            $table->string('project_name');
            $table->text('description')->nullable();
            $table->enum('type', ['INFRASTRUCTURE', 'LIVELIHOOD', 'HEALTH', 'EDUCATION', 'ENVIRONMENT', 'OTHERS'])->default('INFRASTRUCTURE');
            $table->decimal('budget', 15, 2)->nullable();
            $table->enum('fund_source', ['GENERAL_FUND', 'SK', 'PROVINCE', 'NATIONAL', 'OTHERS'])->default('GENERAL_FUND');
            $table->date('start_date')->nullable();
            $table->date('end_date')->nullable();
            $table->enum('status', ['PLANNED', 'ONGOING', 'COMPLETED', 'SUSPENDED', 'CANCELLED'])->default('PLANNED');
            $table->string('implementing_office')->nullable();
            $table->string('contractor')->nullable();
            $table->string('location')->nullable();
            $table->unsignedInteger('beneficiaries_count')->nullable();
            $table->boolean('is_active')->default(true);
            $table->unsignedBigInteger('created_by')->nullable();
            $table->unsignedBigInteger('updated_by')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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