CREATE TABLE IF NOT EXISTS `order_activity_log` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `order_id` BIGINT UNSIGNED NOT NULL,
    `event_type` VARCHAR(32) NOT NULL,
    `summary` VARCHAR(255) NOT NULL,
    `details_json` JSON NULL,
    `actor_type` VARCHAR(16) NOT NULL DEFAULT 'system',
    `actor_name` VARCHAR(128) NULL,
    `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    KEY `order_activity_log_order_created_idx` (`order_id`, `created_at`),
    KEY `order_activity_log_event_type_idx` (`event_type`),
    CONSTRAINT `order_activity_log_order_fk`
        FOREIGN KEY (`order_id`) REFERENCES `orders`(`id`)
        ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
