Skip to main content

toolu_orm_core/
rename.rs

1//! RenameResolver trait for detecting table and column renames during schema diff.
2
3/// Trait for resolving table and column renames during schema diff.
4pub trait RenameResolver {
5  /// Given lists of added and removed table names, return pairs of (old, new)
6  /// names that represent renames rather than drops + creates.
7  fn resolve_tables(&self, added: &[String], removed: &[String]) -> Vec<(String, String)>;
8
9  /// Given lists of added and removed column names within a table, return pairs
10  /// of (old, new) names that represent renames rather than drops + adds.
11  fn resolve_columns(
12    &self,
13    table: &str,
14    added: &[String],
15    removed: &[String],
16  ) -> Vec<(String, String)>;
17}
18
19/// Default resolver that never detects renames.
20pub struct NoRenames;
21
22impl RenameResolver for NoRenames {
23  fn resolve_tables(&self, _added: &[String], _removed: &[String]) -> Vec<(String, String)> {
24    Vec::new()
25  }
26
27  fn resolve_columns(
28    &self,
29    _table: &str,
30    _added: &[String],
31    _removed: &[String],
32  ) -> Vec<(String, String)> {
33    Vec::new()
34  }
35}