<?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('services', function (Blueprint $table) {
            $table->foreignId('image_media_id')->nullable()->after('image')->constrained('media')->nullOnDelete();
            $table->foreignId('icon_media_id')->nullable()->after('icon')->constrained('media')->nullOnDelete();
        });

        Schema::table('settings', function (Blueprint $table) {
            $table->foreignId('logo_media_id')->nullable()->after('logo')->constrained('media')->nullOnDelete();
            $table->foreignId('favicon_media_id')->nullable()->after('favicon')->constrained('media')->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('settings', function (Blueprint $table) {
            $table->dropConstrainedForeignId('logo_media_id');
            $table->dropConstrainedForeignId('favicon_media_id');
        });

        Schema::table('services', function (Blueprint $table) {
            $table->dropConstrainedForeignId('image_media_id');
            $table->dropConstrainedForeignId('icon_media_id');
        });
    }
};
