<?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('page_block', function (Blueprint $table) {
            $table->unsignedBigInteger('page_id');
            $table->unsignedBigInteger('block_id');
            $table->unsignedInteger('position')->nullable();
            $table->foreign('page_id')->references('id')
                ->on('pages')->onDelete('CASCADE')->onUpdate('CASCADE');
            $table->foreign('block_id')->references('id')
                ->on('blocks')->onDelete('CASCADE')->onUpdate('CASCADE');
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('page_block');
    }
};
