<?php

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

/**
 * PRC-1143 — konsolide şema: `client_known_ips` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('client_known_ips', function (Blueprint $t) {
            $t->id();
            $t->unsignedInteger('client_id');
            $t->string('ip', 45)->nullable();
            $t->string('country', 2)->nullable();
            $t->string('city', 255)->nullable();
            $t->text('user_agent')->nullable();
            $t->timestamp('last_seen_at')->nullable();
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->index('client_id', 'client_known_ips_client_id_index');
            $t->index(['client_id', 'last_seen_at'], 'client_known_ips_client_id_last_seen_at_index');
        });
    }

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