<?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('job_sources', function (Blueprint $table) {
            $table->id();
            $table->string('name')->unique();
            $table->string('slug')->unique();
            $table->string('type', 50)->default('manual')->index();
            $table->string('base_url', 2048)->nullable();
            $table->string('feed_url', 2048)->nullable();
            $table->text('attribution_text')->nullable();
            $table->boolean('is_active')->default(true)->index();
            $table->json('sync_settings')->nullable();
            $table->timestamp('last_synced_at')->nullable()->index();
            $table->timestamp('last_failed_at')->nullable()->index();
            $table->text('last_failure_reason')->nullable();
            $table->timestamps();
        });
    }

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