<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('constants', function (Blueprint $table) {
            $table->id();
            $table->string('constant_key')->unique(); // Unique key to identify the constant
            $table->string('constant_value');         // Fixed value of the constant
            $table->string('label');                  // Human-readable label that can change
            $table->string('type');                   // Type or category (e.g., billing_cycle, order_status)
            $table->timestamps();                            // Laravel created_at and updated_at
        });

        // Call the seeder and capture the output
        Artisan::call('db:seed', [
            '--class' => 'Database\\Seeders\\ConstantsTableSeeder',
            '--force' => true,
        ]);

        // Print the output
        echo Artisan::output();
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('constants');
    }
};
