<?php

/**
 * Migration 058 – Extend iw_marketplace_install_log.action ENUM.
 *
 * Adds allowlist_add and allowlist_remove to the action column so
 * registry-allowlist changes are recorded in the audit trail.
 */

use App\Database\Migration;

class ExtendMarketplaceInstallLogAction extends Migration
{
    public function up(): void
    {
        // MODIFY COLUMN is idempotent when re-run with the same definition.
        $this->db->query("
            ALTER TABLE iw_marketplace_install_log
            MODIFY COLUMN action ENUM('install','update','rollback','allowlist_add','allowlist_remove')
                NOT NULL DEFAULT 'install'
        ");
    }

    public function down(): void
    {
        $this->db->query("
            ALTER TABLE iw_marketplace_install_log
            MODIFY COLUMN action ENUM('install','update','rollback')
                NOT NULL DEFAULT 'install'
        ");
    }
}
