<?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::create('rate_import_logs', function (Blueprint $table): void {
            $table->id();
            $table->string('source')->default('guest_google_sheet_reflection');
            $table->foreignId('triggered_by_user_id')->nullable()->constrained('users')->nullOnDelete();
            $table->string('mode')->default('manual');
            $table->string('status')->default('running');
            $table->date('date_from')->nullable();
            $table->date('date_to')->nullable();
            $table->unsignedInteger('rooms_processed')->default(0);
            $table->unsignedInteger('days_processed')->default(0);
            $table->unsignedInteger('rows_written')->default(0);
            $table->text('message')->nullable();
            $table->json('details_json')->nullable();
            $table->timestamp('completed_at')->nullable();
            $table->timestamps();
        });
    }

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