<?php

use App\System;
use Illuminate\Database\Migrations\Migration;

/**
 * Register the BMS module version in the global `system` table.
 *
 * The ERP's ModuleUtil::isModuleInstalled() treats a module as installed only
 * when a `<module>_version` system property exists. Without this, the module's
 * DataController hooks (admin menu, permissions) are skipped. Keyed `bms_version`
 * to match strtolower('Bms').'_version'.
 */
return new class extends Migration {
    public function up(): void
    {
        if (class_exists(System::class)) {
            System::addProperty('bms_version', '1.0.0');
        }
    }

    public function down(): void
    {
        if (class_exists(System::class)) {
            System::removeProperty('bms_version');
        }
    }
};
