<?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('platform_leads', function (Blueprint $table) {
            $table->id();

            // 对外平台线索/开通意向（前期先承接 A：站点开通型）
            $table->string('name', 100)->default('');
            $table->string('mobile', 30)->default('');
            $table->string('email', 100)->default('');
            $table->string('company', 100)->default('');
            $table->string('source', 50)->default('platform');
            $table->string('status', 30)->default('new');
            $table->text('note')->nullable();

            // 预期套餐（可选）
            $table->unsignedBigInteger('plan_id')->nullable()->index();

            // 扩展字段：便于后续接入 B（license）或更复杂的开通信息
            $table->json('meta')->nullable();

            $table->timestamps();

            $table->index(['status', 'created_at']);
        });
    }

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