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

                $table->string('url_image', 250);                   // Logo URL
                $table->string('name', 50);                         // Full OTA Name
                $table->string('sample_name', 50)->unique();        // Compact OTA Name

                $table->boolean('is_active')->default(0);           // Is the OTA active on system?
                $table->boolean('is_connected')->default(0);        // Is system connected with the OTA?
                $table->boolean('is_synchronized')->default(0);     // Is system synchronized with online OTA data?

                $table->json('external_rooms')->nullable();         // External Rooms summary
                $table->string('ota_hotel_id', 64)->nullable();     // External Hotel ID

                $table->unsignedBigInteger('local_agency_id')->nullable();  // Associated Local Agency
                $table->foreign('local_agency_id')
                    ->references('id')->on('agencies')
                    ->onDelete('set null');

            $table->timestamps();
        });
    }

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