<?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('usage_logs', function (Blueprint $table): void {
            $table->id();
            $table->string('bucket_id', 191);
            $table->date('date_key');
            $table->unsignedInteger('used')->default(0);
            $table->unsignedInteger('limit_count')->nullable();
            $table->json('seen_signatures')->nullable();
            $table->timestamps();

            $table->unique(['bucket_id', 'date_key'], 'uniq_bucket_day');
        });
    }

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