<?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('wg_traffic_samples', function (Blueprint $table) {
            $table->id();
            $table->string('peer_pubkey');
            $table->string('peer_name')->nullable();
            $table->unsignedBigInteger('rx')->default(0);
            $table->unsignedBigInteger('tx')->default(0);
            $table->timestamp('sampled_at')->index();
            $table->index(['peer_pubkey', 'sampled_at']);
        });
    }

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