<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('blocks', function (Blueprint $table) {
            if (!Schema::hasColumn('blocks', 'description')) {
                $table->text('description')->nullable()->after('name');
            }
        });

        Schema::table('properties', function (Blueprint $table) {
            $table->string('khasra')->nullable()->after('status');
            $table->string('khewat')->nullable()->after('khasra');
            $table->string('khatouni')->nullable()->after('khewat');
            $table->string('mouza')->nullable()->after('khatouni');
            $table->string('street')->nullable()->after('mouza');
            $table->string('category')->nullable()->after('street'); // e.g. Corner, Park Facing
            $table->boolean('has_installment_plan')->default(false)->after('category');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('blocks', function (Blueprint $table) {
            $table->dropColumn('description');
        });

        Schema::table('properties', function (Blueprint $table) {
            $table->dropColumn(['khasra', 'khewat', 'khatouni', 'mouza', 'street', 'category', 'has_installment_plan']);
        });
    }
};
