<?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('invite_codes', function (Blueprint $table) {
            $table->id();
            $table->string('code', 32)->unique();
            $table->unsignedInteger('created_by_account_id')->nullable()->index();
            $table->string('created_by_username', 32)->nullable();
            $table->unsignedInteger('redeemed_by_account_id')->nullable()->index();
            $table->string('redeemed_by_username', 32)->nullable();
            $table->timestamp('redeemed_at')->nullable()->index();
            $table->timestamps();
        });
    }

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