<?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('products', function (Blueprint $table) {
            $table->id();

            // Identificador único del producto
            $table->string('slug', 100)->unique();

            // Nombre comercial o descriptivo
            $table->string('name', 200);

            // Descripción corta
            $table->string('summary', 500)->nullable();

            // Descripción larga
            $table->text('description')->nullable();

            // Tecnología: moodle | wordpress | saas | api | ...
            $table->string('tech', 50)->nullable();

            // Tipo dentro de Moodle: mod | local | block | theme | etc.
            // En otros tech se quedará null.
            $table->string('type', 50)->nullable();

            // Información adicional específica según tecnología
            $table->json('metadata')->nullable();

            // Control absoluto: el producto funciona o no funciona
            $table->boolean('actived')->default(true);

            // Control comercial: se puede asignar a nuevos tokens
            $table->boolean('enabled')->default(true);

            $table->timestamps();
            $table->softDeletes();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('products');
    }
};
