1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use enum_dispatch::enum_dispatch;
use crate::utils::Errs;
use super::Node;

pub(crate) struct SqliteMigrateCtx {
    pub(crate) errs: Errs,
    pub statements: Vec<String>,
}

impl SqliteMigrateCtx {
    pub fn new(errs: Errs) -> Self {
        Self {
            errs: errs,
            statements: Default::default(),
        }
    }
}

pub(crate) type MigrateNode = crate::graphmigrate::Node<Node>;

#[enum_dispatch]
pub(crate) trait SqliteNodeDataDispatch {
    fn create_coalesce(&mut self, other: Node) -> Option<Node>;
    fn create(&self, ctx: &mut SqliteMigrateCtx);
    fn delete_coalesce(&mut self, other: Node) -> Option<Node>;
    fn delete(&self, ctx: &mut SqliteMigrateCtx);
}

pub(crate) trait SqliteNodeData: SqliteNodeDataDispatch {
    fn update(&self, ctx: &mut SqliteMigrateCtx, old: &Self);
}