Skip to main content

mz_postgres_util/
schema_change.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
10//! Upstream schema changes that Materialize cannot follow.
11
12use serde::{Deserialize, Serialize};
13
14pub use mz_source_schema_change::{KeyRef, SchemaChange};
15
16/// A [`SchemaChange`] on a PostgreSQL table.
17#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, thiserror::Error)]
18#[error("incompatible schema change on {namespace}.{name} (oid {oid}): {change}")]
19pub struct SchemaChangeError {
20    pub namespace: String,
21    pub name: String,
22    pub oid: u32,
23    pub change: SchemaChange,
24}
25
26impl SchemaChangeError {
27    pub fn hint(&self) -> Option<String> {
28        self.change.hint(&self.namespace, &self.name)
29    }
30}