<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('peers', function (Blueprint $table) {
            $table->id();
            $table->uuid('uuid')->unique('uuid');
            $table->datetime('created_at');
            $table->uuid('created_uuid')->index('created_uuid');
            $table->datetime('updated_at');
            $table->uuid('updated_uuid')->index('updated_uuid');
            $table->uuid('torrent_uuid')->index('torrent_uuid');
            $table->string('peer_id', 255)->index('peer_id');
            $table->string('ip', 255);
            $table->smallInteger('port')->default(0);
            $table->tinyInteger('status')->default(1);
            $table->tinyInteger('natuser')->default(0);
            $table->string('client', 255);
            $table->string('dns', 255);
            $table->bigInteger('uploaded')->default(0);
            $table->bigInteger('downloaded')->default(0);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('peers');
    }
};
