<?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('progress_reports', function (Blueprint $table) {
            if (!Schema::hasColumn('progress_reports', 'report_kind')) {
                $table->string('report_kind')->default('daily')->after('status');
            }
            if (!Schema::hasColumn('progress_reports', 'report_payload')) {
                $table->json('report_payload')->nullable()->after('notes');
            }
        });
    }

    public function down(): void
    {
        Schema::table('progress_reports', function (Blueprint $table) {
            if (Schema::hasColumn('progress_reports', 'report_payload')) {
                $table->dropColumn('report_payload');
            }
            if (Schema::hasColumn('progress_reports', 'report_kind')) {
                $table->dropColumn('report_kind');
            }
        });
    }
};
