use crate::ast::identifiers::ObjectId;
use crate::model::relation::RelationOverlay;
use crate::model::sequence::SequenceOverlay;
use crate::model::types::TypeOverlay;
use crate::analysis::graph::{
ColumnDependencyEdge, FkEdge, IndexEdge, PartitionEdge, PublicationEdge, RenameEdge,
SequenceEdge, ViewEdge,
};
use std::collections::HashSet;
#[derive(Debug, Clone)]
pub enum StateChange {
RelationSnapshot {
id: ObjectId,
previous: Box<Option<RelationOverlay>>,
},
TypeSnapshot {
id: ObjectId,
previous: Option<TypeOverlay>,
},
SequenceSnapshot {
id: ObjectId,
previous: Option<SequenceOverlay>,
},
SearchPathSnapshot {
previous: Vec<String>,
},
GenerationCounterSnapshot {
previous: u64,
},
PendingValidationSnapshot {
previous: HashSet<(ObjectId, String)>,
},
FkGraphLengthMarker {
len: usize,
},
FkGraphSnapshot {
previous: Vec<FkEdge>,
},
ViewGraphLengthMarker {
len: usize,
},
ViewGraphSnapshot {
previous: Vec<ViewEdge>,
},
IndexGraphLengthMarker {
len: usize,
},
IndexGraphSnapshot {
previous: Vec<IndexEdge>,
},
RenameGraphLengthMarker {
len: usize,
},
RenameGraphSnapshot {
previous: Vec<RenameEdge>,
},
SequenceGraphLengthMarker {
len: usize,
},
SequenceGraphSnapshot {
previous: Vec<SequenceEdge>,
},
ColumnGraphLengthMarker {
len: usize,
},
ColumnGraphSnapshot {
previous: Vec<ColumnDependencyEdge>,
},
PartitionGraphMarker {
len: usize,
},
PartitionGraphSnapshot {
previous: Vec<PartitionEdge>,
},
FunctionSnapshot {
id: ObjectId,
previous: Option<crate::model::function::FunctionOverlay>,
},
PublicationSnapshot {
id: ObjectId,
previous: Option<crate::model::replication::PublicationOverlay>,
},
SubscriptionSnapshot {
id: ObjectId,
previous: Option<crate::model::replication::SubscriptionOverlay>,
},
RoleSnapshot {
id: ObjectId,
previous: Option<crate::model::role::RoleOverlay>,
},
TriggerSnapshot {
id: ObjectId,
previous: Option<crate::model::trigger::TriggerOverlay>,
},
TriggerGraphSnapshot {
previous: Vec<crate::analysis::graph::TriggerEdge>,
},
PublicationGraphSnapshot {
previous: Vec<PublicationEdge>,
},
CurrentRoleSnapshot {
previous: String,
},
ConfidenceSnapshot {
previous: crate::analysis::state::Confidence,
},
}
#[derive(Debug, Clone)]
pub struct TransactionFrame {
pub name: String,
pub undo_log: Vec<StateChange>,
}
impl TransactionFrame {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
undo_log: Vec::new(),
}
}
}