Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
20 lines
952 B
SQL
20 lines
952 B
SQL
-- Co-Lite change add-lead-dashboard: event lead status history (design decision 1).
|
|
-- Target: `service-counter`. Additive only. Run before the new images go live (services-counter writes this table), then 02.
|
|
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`);
|