<?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('artwork_award_stats', function (Blueprint $table) {
            $table->unsignedBigInteger('artwork_id')->primary();
            $table->unsignedInteger('gold_count')->default(0);
            $table->unsignedInteger('silver_count')->default(0);
            $table->unsignedInteger('bronze_count')->default(0);
            $table->unsignedInteger('score_total')->default(0);
            $table->timestamp('updated_at')->nullable();

            $table->foreign('artwork_id')
                ->references('id')->on('artworks')
                ->cascadeOnDelete();
        });
    }

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