<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
    public function up(): void {
        Schema::create('reading_progress', function (Blueprint $table) {
            $table->id(); $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            $table->foreignId('resource_id')->constrained()->cascadeOnDelete(); $table->string('position')->nullable();
            $table->decimal('percentage', 5, 2)->default(0); $table->timestamp('started_at')->nullable();
            $table->timestamp('last_read_at')->nullable(); $table->timestamp('completed_at')->nullable(); $table->timestamps();
            $table->unique(['user_id', 'resource_id']);
        });
    }
    public function down(): void { Schema::dropIfExists('reading_progress'); }
};
