<?php

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

return new class extends Migration
{

    public function up(): void
    {
        Schema::table('consultant_profiles', function (Blueprint $table) {

            $table->foreignId('company_id')
                ->nullable()
                ->after('user_id')
                ->constrained('companies')
                ->nullOnDelete();

            // Postgres FK kolonuna otomatik index açmaz; firma → danışman sorguları için gerekli.
            $table->index('company_id');
        });
    }


    public function down(): void
    {
        Schema::table('consultant_profiles', function (Blueprint $table) {
            $table->dropConstrainedForeignId('company_id');
        });
    }
};
