-- 审计日志（关键操作留痕）
SET NAMES utf8mb4;

CREATE TABLE IF NOT EXISTS `biz_audit_log` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `admin_user_id` BIGINT UNSIGNED NULL DEFAULT NULL COMMENT '后台操作者 sys_user.id，可空',
  `biz_user_id` BIGINT UNSIGNED NULL DEFAULT NULL COMMENT '相关业务用户',
  `action` VARCHAR(64) NOT NULL COMMENT '动作标识',
  `resource_type` VARCHAR(64) NOT NULL DEFAULT '',
  `resource_id` BIGINT UNSIGNED NULL DEFAULT NULL,
  `detail` JSON NULL,
  `created_at` DATETIME NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_biz_audit_action` (`action`),
  KEY `idx_biz_audit_created` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='订阅模块审计';
