<?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::create('related', function (Blueprint $table) {
            $table->unsignedBigInteger('website_object_id');
            $table->unsignedBigInteger('related_id');
            $table->unsignedInteger('position')->nullable();
            $table->string('type', 50);
            $table->foreign('website_object_id')->references('website_object_id')
                ->on('website_objects')->onDelete('CASCADE')->onUpdate('CASCADE');
            $table->foreign('related_id')->references('website_object_id')
                ->on('website_objects')->onDelete('CASCADE')->onUpdate('CASCADE');
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('related');
    }
};
