fix(migrations): Discover's migrations don't reflect our Prod setup.
Our current discover migrations don't leave Discover in a working state for our Production setup. Discover is a Merge table of our errors and transactions clusters, the current migrations make discover_dist a Distributed table for discover_local which in turn is trying to be a Merge table of errors_local and transactions_local. Since we don't have errors_local and transactions_local in the same cluster as discover_local, this leaves a new setup in a state where Discover is pointing to non-existent tables.
This latest (blocking) migration should get new setups to match our existing Production setup, it drops the existing discover_dist as a Distributed table and replaces it with a Merge table pointing to the errors_dist and transactions_dist tables which are then Distributed tables to their respective clusters.
This PR has a migration; here is the generated SQL
-- start migrations
-- forward migration discover : 0008_discover_fix_dist_merge_table
Distributed op: DROP TABLE IF EXISTS discover_dist;
Distributed op: CREATE TABLE IF NOT EXISTS discover_dist (event_id UUID, project_id UInt64, type LowCardinality(String), timestamp DateTime, platform LowCardinality(String), environment LowCardinality(Nullable(String)), release LowCardinality(Nullable(String)), dist LowCardinality(Nullable(String)), transaction_name LowCardinality(String), message String, title String, user String, user_hash UInt64, user_id Nullable(String), user_name Nullable(String), user_email Nullable(String), ip_address_v4 Nullable(IPv4), ip_address_v6 Nullable(IPv6), sdk_name LowCardinality(Nullable(String)), sdk_version LowCardinality(Nullable(String)), http_method LowCardinality(Nullable(String)), http_referer Nullable(String), tags Nested(key String, value String), _tags_hash_map Array(UInt64), contexts Nested(key String, value String), trace_id Nullable(UUID), span_id Nullable(UInt64), deleted UInt8) ENGINE Merge(currentDatabase(), '^errors_dist$|^transactions_dist$');
-- end forward migration discover : 0008_discover_fix_dist_merge_table
-- backward migration discover : 0008_discover_fix_dist_merge_table
Distributed op: DROP TABLE IF EXISTS discover_dist;
Distributed op: CREATE TABLE IF NOT EXISTS discover_dist (event_id UUID, project_id UInt64, type LowCardinality(String), timestamp DateTime, platform LowCardinality(String), environment LowCardinality(Nullable(String)), release LowCardinality(Nullable(String)), dist LowCardinality(Nullable(String)), transaction_name LowCardinality(String), message String, title String, user String, user_hash UInt64, user_id Nullable(String), user_name Nullable(String), user_email Nullable(String), ip_address_v4 Nullable(IPv4), ip_address_v6 Nullable(IPv6), sdk_name LowCardinality(Nullable(String)), sdk_version LowCardinality(Nullable(String)), http_method LowCardinality(Nullable(String)), http_referer Nullable(String), tags Nested(key String, value String), _tags_hash_map Array(UInt64), contexts Nested(key String, value String), trace_id Nullable(UUID), span_id Nullable(UInt64), deleted UInt8) ENGINE Distributed(`cluster_one_sh`, default, discover_local);
-- end backward migration discover : 0008_discover_fix_dist_merge_table
I think https://github.com/getsentry/snuba/pull/5788 covered this so closing this PR