<?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('bookings', function (Blueprint $table) {
            // Tambahkan kolom measurements
            $table->json('measurements')->nullable()->after('payment_status');
            
            // Tambahkan kolom lain yang diperlukan berdasarkan controller
            $table->json('repair_details')->nullable()->after('measurements');
            $table->string('repair_photo')->nullable()->after('repair_details');
            $table->text('repair_notes')->nullable()->after('repair_photo');
            $table->string('completion_photo')->nullable()->after('repair_notes');
            $table->text('completion_notes')->nullable()->after('completion_photo');
            
            // Tambahkan kolom untuk tracking waktu
            $table->timestamp('accepted_at')->nullable()->after('completion_notes');
            $table->timestamp('rejected_at')->nullable()->after('accepted_at');
            $table->timestamp('completed_at')->nullable()->after('rejected_at');
            $table->text('rejection_reason')->nullable()->after('completed_at');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('bookings', function (Blueprint $table) {
            $table->dropColumn([
                'measurements',
                'repair_details',
                'repair_photo',
                'repair_notes',
                'completion_photo',
                'completion_notes',
                'accepted_at',
                'rejected_at',
                'completed_at',
                'rejection_reason'
            ]);
        });
    }
};
