<?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_locations', function (Blueprint $table) {
            $table->id();
            $table->foreignId('location_id')->constrained('locations');
            $table->string('platform', 32);
            $table->string('external_id', 128);
            $table->string('provider_name')->nullable();
            $table->string('status', 24)->default('unverified');
            $table->timestamp('verified_at')->nullable();
            $table->timestamps();

            $table->unique(['platform', 'external_id']);
            $table->index(['platform', 'location_id', 'status']);
        });
    }

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