<?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('external_systems', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->string('code')->unique();
            $table->string('name');
            $table->text('description')->nullable();
            $table->string('url');
            $table->string('icon')->default('ExternalLink');
            $table->boolean('is_active')->default(true);
            $table->timestamp('starts_at')->nullable();
            $table->timestamp('ends_at')->nullable();
            $table->boolean('opens_in_new_tab')->default(true);
            $table->boolean('sso_enabled')->default(false);
            $table->string('sso_launch_path')->nullable();
            $table->text('sso_secret')->nullable();
            $table->string('sso_audience')->nullable();
            $table->unsignedSmallInteger('sso_token_ttl')->default(120);
            $table->boolean('require_onboarding')->default(true);
            $table->string('contact_email')->nullable();
            $table->text('notes')->nullable();
            $table->unsignedInteger('sort_order')->default(0);
            $table->timestamps();
        });
    }

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