<?php

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

/**
 * Class CreateVzdelavanieKniznicaSekcieTable
 */
return new class extends Migration
{
    /**
     * @return void
     */
    public function up()
    {
        Schema::create('vzdelavanie_kniznica_sekcie', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('ucebnica_id');

            $table->string('nazov', 512)->default('Názov sekcie');
            $table->longText('obsah')->nullable();
            $table->nestedSet();

            $table->foreign('ucebnica_id')->references('id')->on('vzdelavanie_kniznica_ucebnice')->onDelete('cascade');

            $table->timestamps();
        });
    }

    /**
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('vzdelavanie_kniznica_sekcie');
    }
};
