<?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
    {
        \kernel\App::$db->schema->create('user_stage', function (Blueprint $table) {
            $table->id();
            $table->string('slug')->nullable(false);
            $table->string('title')->nullable(false);
            $table->text('description')->nullable(false);
            $table->dateTime('start_date')->nullable();
            $table->dateTime('end_date')->nullable();
            $table->integer('position')->nullable(false)->default(1);
            $table->integer('status')->default(1);
            $table->text('user_fields')->nullable(true);
            $table->timestamps();
        });

        \kernel\App::$db->schema->create('user_stage_progress', function (Blueprint $table) {
            $table->id();
            $table->integer('user_id')->nullable(false);
            $table->integer('user_stage_id')->nullable(false);
            $table->boolean('is_completed')->default(false);
            $table->boolean('is_closed')->default(true);
            $table->integer('status')->default(1);
            $table->timestamp('completed_at')->nullable();
            $table->timestamps();


        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        \kernel\App::$db->schema->dropIfExists('user_stage_progress');
        \kernel\App::$db->schema->dropIfExists('user_stage');
    }
};
