<?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('activations', function (Blueprint $table) {
            $table->id();
            $table->foreignId('license_id')->constrained()->cascadeOnDelete();
            $table->string('domain');
            $table->string('site_url')->nullable();
            $table->string('instance_token')->unique();
            $table->string('plugin_version')->nullable();
            $table->string('wp_version')->nullable();
            $table->string('ip_address')->nullable();
            $table->timestamp('last_checked_at')->nullable();
            $table->timestamps();

            $table->unique(['license_id', 'domain']);
        });
    }

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