<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * Alters the self_paced_topics table to add:
     * - Minimum time requirement (in seconds)
     * - Maximum time (informational/display only, in seconds)
     *
     * Requirements: 3.1
     */
    public function up(): void
    {
        Schema::table('self_paced_topics', function (Blueprint $table) {
            $table->unsignedInteger('min_time_seconds')
                ->nullable()
                ->after('is_published')
                ->comment('Minimum seconds learner must spend on topic before marking complete');

            $table->unsignedInteger('max_time_seconds')
                ->nullable()
                ->after('min_time_seconds')
                ->comment('Maximum time for display purposes only (not enforced)');
        });
    }

    public function down(): void
    {
        Schema::table('self_paced_topics', function (Blueprint $table) {
            $table->dropColumn([
                'min_time_seconds',
                'max_time_seconds',
            ]);
        });
    }
};
