<?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::create('price_sync_runs', function (Blueprint $table) {
            $table->id();
            $table->string('provider')->default('dataforseo_merchant_google_products')->index();
            $table->string('status')->default('running')->index();
            $table->timestamp('started_at')->nullable()->index();
            $table->timestamp('finished_at')->nullable();
            $table->unsignedInteger('total_targets')->default(0);
            $table->unsignedInteger('tasks_submitted')->default(0);
            $table->unsignedInteger('matched_count')->default(0);
            $table->unsignedInteger('not_matched_count')->default(0);
            $table->unsignedInteger('ambiguous_count')->default(0);
            $table->unsignedInteger('empty_results_count')->default(0);
            $table->unsignedInteger('api_error_count')->default(0);
            $table->unsignedInteger('error_count')->default(0);
            $table->json('summary')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('price_sync_runs');
    }
};
