<?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('website_type', function (Blueprint $table): void {
            $table->unsignedBigInteger('footer_logo')->nullable()->after('site_logo');

            $table->foreign('footer_logo')
                ->references('id')
                ->on('attachments')
                ->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('website_type', function (Blueprint $table): void {
            if (Schema::getConnection()->getDriverName() !== 'sqlite') {
                $table->dropForeign(['footer_logo']);
            }

            $table->dropColumn('footer_logo');
        });
    }
};
