<?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('observed_items', function (Blueprint $table) {
            $table->foreign(['road_item_id'])->references(['id'])->on('road_items_projects')->onUpdate('cascade')->onDelete('set null');
            $table->foreign(['road_patrol_id'])->references(['id'])->on('road_patrols')->onUpdate('cascade')->onDelete('set null');
        });
    }

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