<?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('artworks', function (Blueprint $table): void {
            $table->float('trending_score_24h', 10, 4)->default(0)->after('is_approved')->index();
            $table->float('trending_score_7d', 10, 4)->default(0)->after('trending_score_24h')->index();
            $table->timestamp('last_trending_calculated_at')->nullable()->after('trending_score_7d');
        });
    }

    public function down(): void
    {
        Schema::table('artworks', function (Blueprint $table): void {
            $table->dropIndex(['trending_score_24h']);
            $table->dropIndex(['trending_score_7d']);
            $table->dropColumn(['trending_score_24h', 'trending_score_7d', 'last_trending_calculated_at']);
        });
    }
};
