good_ormning/pg/graph/
utils.rs1use enum_dispatch::enum_dispatch;
2use crate::utils::Errs;
3use super::Node;
4
5pub(crate) struct PgMigrateCtx {
6 pub(crate) errs: Errs,
7 pub statements: Vec<String>,
8}
9
10impl PgMigrateCtx {
11 pub fn new(errs: Errs) -> Self {
12 Self {
13 errs: errs,
14 statements: Default::default(),
15 }
16 }
17}
18
19pub(crate) type MigrateNode = crate::graphmigrate::Node<Node>;
20
21#[enum_dispatch]
22pub(crate) trait NodeDataDispatch {
23 fn create_coalesce(&mut self, other: Node) -> Option<Node>;
24 fn create(&self, ctx: &mut PgMigrateCtx);
25 fn delete_coalesce(&mut self, other: Node) -> Option<Node>;
26 fn delete(&self, ctx: &mut PgMigrateCtx);
27}
28
29pub(crate) trait NodeData: NodeDataDispatch {
30 fn update(&self, ctx: &mut PgMigrateCtx, old: &Self);
31}