-- =========================================================
-- MIGRATION: Admin Audit Log
-- Records every sensitive admin action for accountability.
-- =========================================================

CREATE TABLE IF NOT EXISTS admin_logs (
    id              INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    admin_id        INT UNSIGNED     NOT NULL,
    action          VARCHAR(60)      NOT NULL,   -- e.g. 'suspend_user','adjust_balance','force_verify'
    target_user_id  INT UNSIGNED     DEFAULT NULL,
    details         TEXT             DEFAULT NULL,
    ip_address      VARCHAR(45)      DEFAULT NULL,
    created_at      DATETIME         NOT NULL DEFAULT CURRENT_TIMESTAMP,

    CONSTRAINT fk_adminlogs_admin FOREIGN KEY (admin_id) REFERENCES admins(id) ON DELETE CASCADE,

    INDEX idx_adminlogs_target (target_user_id),
    INDEX idx_adminlogs_admin (admin_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
