<?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('course_contents', function (Blueprint $table) {
            $table->id();
            $table->foreignId('course_id')->constrained()->onDelete('cascade');
            $table->string('title'); // Ej: Lectura Obligatoria - Guía DSM-5
            $table->text('description')->nullable();
            
            // Campo clave para saber qué tipo de contenido es
            $table->enum('type', ['video', 'audio', 'document'])->default('document');
            
            // Ruta del archivo en el servidor o URL externa (si es un video de Vimeo/YouTube)
            $table->string('file_path'); 
            
            $table->integer('order')->default(0); // Para ordenar el temario
            $table->timestamps();
        });
    }

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