-- Create the utils_auditlog table
CREATE TABLE IF NOT EXISTS `utils_auditlog` (
    `id` char(32) NOT NULL,
    `action` varchar(50) NOT NULL,
    `model_name` varchar(100) NOT NULL,
    `object_id` varchar(50) NOT NULL,
    `description` longtext NOT NULL,
    `ip_address` char(39) DEFAULT NULL,
    `user_agent` varchar(255) DEFAULT NULL,
    `created_at` datetime(6) NOT NULL,
    `user_id` char(32) DEFAULT NULL,
    PRIMARY KEY (`id`),
    KEY `utils_auditlog_user_id_idx` (`user_id`),
    KEY `utils_auditlog_created_at_idx` (`created_at`),
    CONSTRAINT `utils_auditlog_user_id_fk` 
        FOREIGN KEY (`user_id`) 
        REFERENCES `users_customuser` (`id`) 
        ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
