<?php

use App\Models\InstagramAccount;
use App\Models\InstagramRepost;
use App\Models\Job;
use App\Models\JobInfo;
use App\Models\JobInfoType;
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
    {
        $newJobId = 5;
        Job::forceCreate([
            "id" => $newJobId,
            "name" => "Eldorado Robux Price Sentry",
            "description" => "Surveille les prix des Robux sur Eldorado.",
        ]);

        $decimalType = JobInfoType::create([
            "name" => "decimal",
        ]);

        JobInfo::forceCreate([
            "key" => "eldorado_robux_price_threshold",
            "name" => "Seuil de prix des Robux",
            "description" => "Le seuil de prix par robux en euros pour déclencher une alerte.",
            "placeholder" => "0,00350",
            "is_required" => true,
            "job_info_type_id" => $decimalType->id,
            "job_id" => $newJobId,
        ]);

        JobInfo::forceCreate([
            "key" => "eldorado_robux_price_discord_webhook",
            "name" => "Webhook Discord pour les alertes de prix des Robux",
            "description" => "L'URL du webhook Discord pour recevoir les alertes de prix des Robux.",
            "placeholder" => "https://discord.com/api/webhooks/...",
            "is_required" => false,
            "job_info_type_id" => 4,
            "job_id" => $newJobId,
        ]);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Job::where("id", 5)->delete();
        JobInfo::where("job_id", 5)->delete();
    }
};
