<?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('vpn_connections', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->onDelete('cascade');
            $table->foreignId('server_id')->constrained('vpn_servers')->onDelete('cascade');
            $table->string('protocol')->default('WireGuard');
            $table->timestamp('connected_at')->nullable();
            $table->timestamp('disconnected_at')->nullable();
            $table->bigInteger('bytes_downloaded')->default(0);
            $table->bigInteger('bytes_uploaded')->default(0);
            $table->string('status')->default('connected'); // connected, disconnected
            $table->timestamps();
        });
    }

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