#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TriggerEvent {
Insert,
Update {
columns: Option<Vec<String>>,
},
Delete,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TriggerTiming {
Before,
After,
InsteadOf,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TriggerScope {
Row,
Statement,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TriggerOrder {
Precedes(String),
Follows(String),
}
#[derive(Debug, Clone, PartialEq)]
pub enum TriggerBody {
Single(String),
Multiple(Vec<String>),
PostgresFunction(String),
}
impl TriggerBody {
pub fn single<S: Into<String>>(statement: S) -> Self {
Self::Single(statement.into())
}
pub fn multiple<I, S>(statements: I) -> Self
where
I: IntoIterator<Item = S>,
S: Into<String>,
{
Self::Multiple(statements.into_iter().map(|s| s.into()).collect())
}
pub fn postgres_function<S: Into<String>>(function_name: S) -> Self {
Self::PostgresFunction(function_name.into())
}
}