diff --git a/xuqm-bugcollect-service/src/main/resources/db/migration/V6__build_id.sql b/xuqm-bugcollect-service/src/main/resources/db/migration/V6__build_id.sql index 6008141..93315bb 100644 --- a/xuqm-bugcollect-service/src/main/resources/db/migration/V6__build_id.sql +++ b/xuqm-bugcollect-service/src/main/resources/db/migration/V6__build_id.sql @@ -1,4 +1,20 @@ -- V6: build_id support for multi-build-per-version sourcemap tracking --- All DDL was applied manually during the initial migration incident. --- This script is intentionally a no-op to let Flyway record V6 as done. -SELECT 1; +-- +-- Adds build_id to log_issue_events and log_sourcemaps so each unique +-- (appKey, platform, appVersion, buildId, bundleName) combination can +-- store its own sourcemap file without overwriting sibling builds. +-- +-- Existing deployments where this column was already added manually: +-- Flyway will have recorded V6 as done via the old no-op; those databases +-- have the column already. For any deployment where V6 ran as a no-op +-- and the column is still missing, run the repair migration V7. + +ALTER TABLE log_issue_events + ADD COLUMN build_id VARCHAR(32) NULL + COMMENT 'Build identifier for sourcemap tracking' + AFTER app_version; + +ALTER TABLE log_sourcemaps + ADD COLUMN build_id VARCHAR(32) NULL + COMMENT 'Build identifier for multi-build-per-version sourcemap tracking' + AFTER app_version; diff --git a/xuqm-bugcollect-service/src/main/resources/db/migration/V7__build_id_repair.sql b/xuqm-bugcollect-service/src/main/resources/db/migration/V7__build_id_repair.sql new file mode 100644 index 0000000..8bac0eb --- /dev/null +++ b/xuqm-bugcollect-service/src/main/resources/db/migration/V7__build_id_repair.sql @@ -0,0 +1,30 @@ +-- V7: repair for deployments where V6 ran as a no-op +-- +-- On some deployments V6 was recorded as done but contained only SELECT 1, +-- leaving build_id missing from log_issue_events and log_sourcemaps. +-- This migration adds the column idempotently using a prepared statement so +-- it is safe whether the column already exists or not. + +SET @_add_lie = IF( + NOT EXISTS ( + SELECT 1 FROM information_schema.columns + WHERE table_schema = DATABASE() + AND table_name = 'log_issue_events' + AND column_name = 'build_id' + ), + 'ALTER TABLE log_issue_events ADD COLUMN build_id VARCHAR(32) NULL COMMENT ''Build identifier for sourcemap tracking'' AFTER app_version', + 'SELECT 1 /* log_issue_events.build_id already exists */' +); +PREPARE _s FROM @_add_lie; EXECUTE _s; DEALLOCATE PREPARE _s; + +SET @_add_lsm = IF( + NOT EXISTS ( + SELECT 1 FROM information_schema.columns + WHERE table_schema = DATABASE() + AND table_name = 'log_sourcemaps' + AND column_name = 'build_id' + ), + 'ALTER TABLE log_sourcemaps ADD COLUMN build_id VARCHAR(32) NULL COMMENT ''Build identifier for multi-build-per-version sourcemap tracking'' AFTER app_version', + 'SELECT 1 /* log_sourcemaps.build_id already exists */' +); +PREPARE _s FROM @_add_lsm; EXECUTE _s; DEALLOCATE PREPARE _s;