<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * Creates the organizations table to store organization details including
     * basic information, contact details, location, and social media links.
     *
     * @return void
     */
    public function up(): void
    {
        Schema::create('organizations', function (Blueprint $table) {
            // Primary key
            $table->id();

            // Basic organization information
            $table->string('name', 191)->unique();
            $table->string('short_name', 191);

            // Location information
            $table->string('country', 191);
            $table->string('city', 191);
            $table->text('postal_address');
            $table->string('postal_code', 20);
            $table->text('physical_address');

            // Contact information
            $table->string('email', 191);
            $table->string('hotline', 50);

            // Formation details
            $table->integer('year_of_formation');

            // Social media links stored as JSON
            $table->json('social_media_links')->nullable();

            // Timestamps and soft deletes
            $table->timestamps();
            $table->softDeletes();

            // Indexes for frequently queried columns
            $table->index('name');
            $table->index('country');
            $table->index('city');
        });
    }

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