<?php

class Migration_20241203114037_alter_audit_logs_add_logging_columns
{
    public static function up(PDO $pdo)
    {
        $query = "
            ALTER TABLE audit_logs
            ADD COLUMN ip_address VARCHAR(45) NULL AFTER property_id,
            ADD COLUMN module_name VARCHAR(100) NULL AFTER ip_address,
            ADD COLUMN log_level VARCHAR(50) NULL AFTER module_name,
            ADD COLUMN user_email VARCHAR(256) NULL AFTER log_level,
            ADD COLUMN timestamp DATETIME NULL AFTER log_level;
        ";

        $pdo->exec($query);

    }

    public static function down(PDO $pdo)
    {
        $query = "
            ALTER TABLE audit_logs
            DROP COLUMN ip_address,
            DROP COLUMN module_name,
            DROP COLUMN log_level,
            DROP COLUMN timestamp;
        ";

        $pdo->exec($query);
        echo "Columns removed from `audit_logs` table successfully.\n";
    }
}
