<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('accident_damage', function (Blueprint $table) {
            $table->foreign(['accident_id'], 'accident_damage_ibfk_1')->references(['id'])->on('accidents')->onUpdate('cascade')->onDelete('set null');
            $table->foreign(['damage_id'], 'accident_damage_ibfk_2')->references(['id'])->on('damages')->onUpdate('cascade')->onDelete('set null');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('accident_damage', function (Blueprint $table) {
            $table->dropForeign('accident_damage_ibfk_1');
            $table->dropForeign('accident_damage_ibfk_2');
        });
    }
};
