This commit is contained in:
Your Name
2026-11-09 14:51:31 +08:00
parent 01a46ee06f
commit 06afe2c453
20 changed files with 1241 additions and 25 deletions
@@ -0,0 +1,42 @@
-- Upgrade after both existing mobile_recording_binding and mobile_recording_media migrations.
-- Existing uploads without a ready object ledger remain readable from private local storage.
-- Encryption keys are server-only secrets: never expose this table via generic admin export/API.
CREATE TABLE IF NOT EXISTS `zyt_mobile_recording_object` (
`upload_id` char(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`backend` varchar(16) NOT NULL DEFAULT 'cos',
`bucket` varchar(100) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`region` varchar(48) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`object_key` varchar(160) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`version_id` varchar(256) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
`encryption_key` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`nonce_prefix` char(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`cipher_format` varchar(32) NOT NULL DEFAULT 'aes256gcm-frame-v1',
`context_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`kind` varchar(16) NOT NULL,
`plain_size` bigint unsigned NOT NULL,
`plain_sha256` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`cipher_size` bigint unsigned NOT NULL,
`multipart_id` varchar(1024) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
`part_etags` mediumtext NOT NULL,
`state` varchar(16) NOT NULL DEFAULT 'pending',
`attempts` int unsigned NOT NULL DEFAULT 0,
`next_retry_at` int unsigned NOT NULL DEFAULT 0,
`created_at` int unsigned NOT NULL,
`updated_at` int unsigned NOT NULL,
PRIMARY KEY (`upload_id`),
UNIQUE KEY `uq_cos_media_location` (`bucket`, `region`, `object_key`),
KEY `idx_cos_media_work` (`state`, `next_retry_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Separate from the object intent: permission/configuration failures can precede COS allocation.
-- Missing work row means staging cleanup is not yet acknowledged; never infer cleanup from publication.
CREATE TABLE IF NOT EXISTS `zyt_mobile_recording_work` (
`upload_id` char(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`attempts` int unsigned NOT NULL DEFAULT 0,
`next_retry_at` int unsigned NOT NULL DEFAULT 0,
`last_attempt_at` int unsigned NOT NULL DEFAULT 0,
`last_result` varchar(16) NOT NULL DEFAULT '',
`staging_cleaned` tinyint unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`upload_id`),
KEY `idx_media_work_retry` (`next_retry_at`, `last_attempt_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;