<?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::table('enrollments', function (Blueprint $table) {
            // Añadimos el token de Flow (puede ser null al principio) y el monto cobrado
            $table->string('flow_order_id')->nullable()->unique()->after('course_id');
            $table->integer('amount')->default(0)->after('status');
            
            // Modificamos el comportamiento por defecto de status para aceptar 'pending'
            $table->string('status')->default('pending')->change();
        });
    }

    public function down(): void
    {
        Schema::table('enrollments', function (Blueprint $table) {
            $table->dropColumn(['flow_order_id', 'amount']);
        });
    }
};