持久化设备留言待收听状态并支持重启恢复
This commit is contained in:
@@ -40,6 +40,7 @@ MINI_PROGRAM_TABLES = [
|
||||
"device_alarm_events",
|
||||
"im_conversations",
|
||||
"im_messages",
|
||||
"device_pending_voice_messages",
|
||||
"child_location_current",
|
||||
"child_location_history",
|
||||
]
|
||||
|
||||
@@ -455,6 +455,29 @@ CREATE TABLE IF NOT EXISTS `im_messages` (
|
||||
ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Persistent unread voice-message index for device NFC owner-card playback.
|
||||
-- Audio content is still stored by im_messages/media_file_key; this table only stores delivery state.
|
||||
CREATE TABLE IF NOT EXISTS `device_pending_voice_messages` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||
`target_device_id` VARCHAR(64) NOT NULL,
|
||||
`sender_device_id` VARCHAR(64) NULL,
|
||||
`im_message_id` BIGINT NOT NULL,
|
||||
`media_file_key` VARCHAR(255) NOT NULL,
|
||||
`audio_url` VARCHAR(512) NULL,
|
||||
`source` VARCHAR(32) NOT NULL DEFAULT 'unknown',
|
||||
`status` VARCHAR(32) NOT NULL DEFAULT 'pending',
|
||||
`delivery_count` INT NOT NULL DEFAULT 0,
|
||||
`delivered_at` DATETIME NULL,
|
||||
`listened_at` DATETIME NULL,
|
||||
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uq_device_pending_voice_target_msg` (`target_device_id`, `im_message_id`),
|
||||
KEY `idx_device_pending_voice_target_status_created` (`target_device_id`, `status`, `created_at`),
|
||||
KEY `idx_device_pending_voice_sender` (`sender_device_id`),
|
||||
KEY `idx_device_pending_voice_im_message` (`im_message_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `child_location_current` (
|
||||
`child_id` BIGINT NOT NULL,
|
||||
`device_id` VARCHAR(64) NOT NULL,
|
||||
|
||||
Reference in New Issue
Block a user