<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('lessons', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->foreignUuid('module_id')->constrained('modules')->cascadeOnDelete();
            $table->string('title');
            $table->string('slug')->unique();
            $table->string('type')->default('text'); // video, text, quiz, vocab_list
            $table->longText('content')->nullable(); // For text lessons or transcripts
            $table->string('video_url')->nullable(); // For video lessons
            $table->string('content_pdf')->nullable(); // For PDF content
            $table->integer('duration_seconds')->default(0); 
            $table->boolean('is_free_preview')->default(false);
            $table->integer('order_index')->default(0);
            $table->json('metadata')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('lessons');
    }
};
