<?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::table('user_progress', function (Blueprint $table) {
            $table->timestamp('started_at')->nullable()->after('lesson_id');
            $table->unsignedInteger('time_spent_seconds')->default(0)->after('completed_at');
            $table->timestamp('last_heartbeat_at')->nullable()->after('time_spent_seconds');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('user_progress', function (Blueprint $table) {
            $table->dropColumn(['started_at', 'time_spent_seconds', 'last_heartbeat_at']);
        });
    }
};
