<?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_stats', function (Blueprint $table) {
            $table->foreignId('artwork_id')->primary()->constrained()->cascadeOnDelete();

            $table->unsignedBigInteger('views')->default(0);
            $table->unsignedBigInteger('downloads')->default(0);
            $table->unsignedBigInteger('favorites')->default(0);

            $table->float('rating_avg', 4, 2)->default(0);
            $table->unsignedInteger('rating_count')->default(0);
        });
    }

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