<?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('company_profiles', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('account_id')->nullable()->unique();
            $table->string('name', 255)->nullable();
            $table->string('employee_count', 20)->nullable();
            $table->string('email', 255)->nullable();
            $table->string('phone', 20)->nullable();
            $table->string('phone_prefix', 10)->nullable();
            $table->string('website_url', 255)->nullable();

            $table->string('company_image', 255)->nullable();
            $table->string('cover_image', 255)->nullable();
            $table->string('cover_image_original', 255)->nullable();
            $table->integer('cover_image_size')->nullable();

            $table->text('description')->nullable();
            $table->string('instagram_url', 255)->nullable();
            $table->string('linkedin_url', 255)->nullable();
            $table->string('facebook_url', 255)->nullable();

            $table->string('subtitle', 255)->nullable();
            $table->string('location', 255)->nullable();
            $table->boolean('is_active')->default(false);
            $table->timestamps();

            $table->foreign('account_id')
                ->references('id')
                ->on('accounts')
                ->onDelete('SET NULL')
                ->onUpdate('CASCADE');

            $table->index('is_active');
            $table->index('name');
        });
    }

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