--liquibase formatted sql

--changeset codex:feature_usage_log
--preconditions onFail:MARK_RAN
--precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'feature_usage_log'
--comment: Track report management and truck routing summary page views, downloads, and prints
CREATE TABLE `feature_usage_log` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `user_id` bigint NOT NULL,
  `username` varchar(64) NOT NULL,
  `feature_code` varchar(64) NOT NULL,
  `action_type` varchar(32) NOT NULL,
  `detail` varchar(512) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_feature_usage_feature_created` (`feature_code`, `created_at`),
  KEY `idx_feature_usage_user_feature` (`user_id`, `feature_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
