From a2a369aa19e3e309633128059dd2fe62b5550f49 Mon Sep 17 00:00:00 2001 From: ngqile Date: Tue, 1 Dec 2026 09:54:34 +0800 Subject: [PATCH] feat(db): event lead status history table and Dashboard module Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- local/seed/03-colite.sql | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/local/seed/03-colite.sql b/local/seed/03-colite.sql index 5b6f765..9bcabb6 100644 --- a/local/seed/03-colite.sql +++ b/local/seed/03-colite.sql @@ -228,3 +228,28 @@ WHERE u.`type` = 'A' AND EXISTS (SELECT 1 FROM `users_roles` r WHERE r.`user_id` UPDATE `user` u SET u.`company_id` = 1, u.`username` = CONCAT(u.`username`, '@ins') WHERE u.`type` = 'A' AND NOT EXISTS (SELECT 1 FROM `users_roles` r WHERE r.`user_id` = u.`id` AND r.`role_id` = 1); + +-- add-lead-dashboard/sql/01-status-change.sql (02 backfill has nothing to do on an empty volume) +USE `service-counter`; + +CREATE TABLE IF NOT EXISTS `event_lead_status_change` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `company_id` bigint NOT NULL, + `event_lead_id` bigint NOT NULL, + `from_status` varchar(10) NULL, + `to_status` varchar(10) NOT NULL, + `changed_at` datetime NOT NULL, + `changed_by` varchar(255) NULL, + PRIMARY KEY (`id`), + KEY `idx_elsc_event_lead` (`event_lead_id`, `changed_at`), + KEY `idx_elsc_company_to_changed` (`company_id`, `to_status`, `changed_at`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- Dashboard capture query: captures by company and capture time. +ALTER TABLE `event_lead` ADD KEY `idx_event_lead_company_captured` (`company_id`, `captured_at`); + +-- add-lead-dashboard/sql/03-dashboard-module.sql +USE `service-system`; + +INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES + (40050000, 'BO_DASHBOARD', 'Dashboard', 'BO', 'M', 40000000, '/', 'LayoutDashboard');