<?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::table('providers', function (Blueprint $table) {
            $table->unsignedBigInteger('document_front_media_id')->nullable()->after('profile_media_id');
            $table->unsignedBigInteger('document_back_media_id')->nullable()->after('document_front_media_id');
            $table->foreign('document_front_media_id')->references('id')->on('media')->nullOnDelete();
            $table->foreign('document_back_media_id')->references('id')->on('media')->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('providers', function (Blueprint $table) {
            $table->dropForeign(['document_front_media_id']);
            $table->dropForeign(['document_back_media_id']);
            $table->dropColumn(['document_front_media_id', 'document_back_media_id']);
        });
    }
};
