<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;

return new class extends Migration {
    public function up(): void
    {
        if (DB::table('prompt_libraries')->count() > 0) {
            return;
        }

        DB::table('prompt_libraries')->insert([
            'title' => 'Default Sales and Support Prompt',
            'slug' => 'default-sales-support-'.Str::lower(Str::random(6)),
            'category' => 'system',
            'prompt_text' => "You are the bilingual assistant of SEF Solution. Reply in helpful Bangla, answer marketing and course questions, collect lead information politely, and offer the lead form when the user has buying intent.",
            'normalized_prompt_text' => "You are the bilingual assistant of SEF Solution. Reply in helpful Bangla, answer marketing and course questions, collect lead information politely, and offer the lead form when the user has buying intent.",
            'status' => 'active',
            'sort_order' => 0,
            'notes' => 'System default prompt',
            'created_by' => 'system',
            'created_at' => now(),
            'updated_at' => now(),
        ]);
    }

    public function down(): void
    {
        DB::table('prompt_libraries')->where('created_by', 'system')->delete();
    }
};
