-- V5: Audit log for admin operations (Spring Boot 3 optimization)

CREATE TABLE IF NOT EXISTS audit_log
(
    id            INTEGER      NOT NULL PRIMARY KEY AUTO_INCREMENT,
    admin_id      INTEGER,
    admin_name    VARCHAR(100),
    action_type   VARCHAR(50)  NOT NULL,
    target_type   VARCHAR(50),
    target_id     INTEGER,
    description   VARCHAR(500),
    status        VARCHAR(20)  NOT NULL DEFAULT 'success',
    create_time   DATETIME
);

CREATE INDEX idx_audit_admin_time ON audit_log(admin_id, create_time DESC);
CREATE INDEX idx_audit_target ON audit_log(target_type, target_id);
