fix(db): 修复 sourcemap 上传因唯一约束缺少 build_id 导致 HTTP 500

uk_map 约束为 (app_key, platform, app_version, bundle_name),未包含
build_id。Gradle 插件每次构建生成不同 buildId,服务端查不到记录后尝试
INSERT,触发 Duplicate entry 约束冲突返回 500。

V8 migration:删除旧约束,重建为
(app_key, platform, app_version, build_id, bundle_name)。
MySQL UNIQUE 对 NULL 视为不相等,历史 build_id=NULL 记录不受影响;
应用层已通过 findByBuildIdIsNull 防止 NULL 记录重复插入。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
XuqmGroup 2026-06-24 15:19:03 +08:00
父节点 bb40b13189
当前提交 a934abe7aa

查看文件

@ -0,0 +1,14 @@
-- V8: Include build_id in log_sourcemaps unique constraint.
--
-- Problem: uk_map was (app_key, platform, app_version, bundle_name).
-- When the Gradle plugin uploads mapping files with a per-build buildId,
-- each new build of the same version generates a different buildId and tries
-- to INSERT a new row, which violates the old constraint → HTTP 500.
--
-- Fix: rebuild uk_map to include build_id.
-- MySQL treats NULLs as distinct in unique indexes, so legacy records
-- (build_id IS NULL) coexist without conflict. Application logic already
-- prevents duplicate NULL-buildId rows via findByAppKeyAndPlatformAndAppVersionAndBuildIdIsNullAndBundleName.
ALTER TABLE log_sourcemaps DROP INDEX uk_map;
ALTER TABLE log_sourcemaps ADD UNIQUE KEY uk_map (app_key, platform, app_version, build_id, bundle_name);