mz_catalog/durable/upgrade/v72_to_v73.rs
1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10use crate::durable::upgrade::MigrationAction;
11use crate::durable::upgrade::{objects_v72 as v72, objects_v73 as v73};
12
13/// Adds the introspection source index global ID variant. Included in this change is shortening
14/// cluster IDs from 64 bits to 32 bits.
15pub fn upgrade(
16 snapshot: Vec<v72::StateUpdateKind>,
17) -> Vec<MigrationAction<v72::StateUpdateKind, v73::StateUpdateKind>> {
18 let mut migrations = Vec::new();
19
20 for update in snapshot {
21 match update.kind {
22 // Attempting to duplicate the introspection source index ID allocation logic in this
23 // file would be extremely cumbersome and error-prone. Instead, we delete all existing
24 // introspection source indexes and let the builtin migration code recreate them with
25 // the new correct IDs.
26 Some(v72::state_update_kind::Kind::ClusterIntrospectionSourceIndex(_)) => {
27 let migration = MigrationAction::Delete(update);
28 migrations.push(migration);
29 }
30 _ => {}
31 }
32 }
33
34 migrations
35}