pub struct Trigger {
pub name: String,
pub schema: Option<String>,
pub table_name: String,
pub table_schema: Option<String>,
pub timing: TriggerTiming,
pub events: Vec<TriggerEvent>,
pub orientation: TriggerOrientation,
pub function_name: String,
pub function_schema: Option<String>,
pub condition: Option<String>,
pub update_columns: Option<Vec<String>>,
pub referencing: Option<TriggerReferencing>,
}Expand description
Represents a PostgreSQL trigger
Fields§
§name: String§schema: Option<String>§table_name: String§table_schema: Option<String>§timing: TriggerTiming§events: Vec<TriggerEvent>§orientation: TriggerOrientation§function_name: String§function_schema: Option<String>§condition: Option<String>§update_columns: Option<Vec<String>>§referencing: Option<TriggerReferencing>Implementations§
Source§impl Trigger
impl Trigger
Sourcepub fn new(
name: impl Into<String>,
table_name: impl Into<String>,
timing: TriggerTiming,
events: Vec<TriggerEvent>,
function_name: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, table_name: impl Into<String>, timing: TriggerTiming, events: Vec<TriggerEvent>, function_name: impl Into<String>, ) -> Self
Create a new trigger
Sourcepub fn with_schema(self, schema: impl Into<String>) -> Self
pub fn with_schema(self, schema: impl Into<String>) -> Self
Set schema
Sourcepub fn with_table_schema(self, schema: impl Into<String>) -> Self
pub fn with_table_schema(self, schema: impl Into<String>) -> Self
Set table schema
Sourcepub fn with_orientation(self, orientation: TriggerOrientation) -> Self
pub fn with_orientation(self, orientation: TriggerOrientation) -> Self
Set trigger orientation
Sourcepub fn with_function_schema(self, schema: impl Into<String>) -> Self
pub fn with_function_schema(self, schema: impl Into<String>) -> Self
Set function schema
Sourcepub fn with_condition(self, condition: impl Into<String>) -> Self
pub fn with_condition(self, condition: impl Into<String>) -> Self
Add a condition (WHEN clause)
Sourcepub fn with_update_columns(self, columns: Vec<String>) -> Self
pub fn with_update_columns(self, columns: Vec<String>) -> Self
Set specific columns for UPDATE triggers (UPDATE OF columns)
Sourcepub fn with_referencing(self, referencing: TriggerReferencing) -> Self
pub fn with_referencing(self, referencing: TriggerReferencing) -> Self
Set transition table references
Sourcepub fn qualified_name(&self) -> String
pub fn qualified_name(&self) -> String
Get the fully qualified trigger name
Sourcepub fn qualified_table_name(&self) -> String
pub fn qualified_table_name(&self) -> String
Get the fully qualified table name
Sourcepub fn qualified_function_name(&self) -> String
pub fn qualified_function_name(&self) -> String
Get the fully qualified function name
Sourcepub fn generate_create_ddl(&self) -> String
pub fn generate_create_ddl(&self) -> String
Generate CREATE TRIGGER DDL
Sourcepub fn generate_drop_ddl(&self) -> String
pub fn generate_drop_ddl(&self) -> String
Generate DROP TRIGGER DDL
Sourcepub fn generate_disable_ddl(&self) -> String
pub fn generate_disable_ddl(&self) -> String
Generate DDL to disable trigger
Sourcepub fn generate_enable_ddl(&self) -> String
pub fn generate_enable_ddl(&self) -> String
Generate DDL to enable trigger
Sourcepub fn fires_on_event(&self, event: &TriggerEvent) -> bool
pub fn fires_on_event(&self, event: &TriggerEvent) -> bool
Check if this trigger fires on a specific event
Sourcepub fn is_row_level(&self) -> bool
pub fn is_row_level(&self) -> bool
Check if this trigger is row-level
Sourcepub fn is_statement_level(&self) -> bool
pub fn is_statement_level(&self) -> bool
Check if this trigger is statement-level
Sourcepub fn has_condition(&self) -> bool
pub fn has_condition(&self) -> bool
Check if this trigger has a condition
Sourcepub fn events_as_string(&self) -> String
pub fn events_as_string(&self) -> String
Get the events as a comma-separated string
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Trigger
impl<'de> Deserialize<'de> for Trigger
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Trigger
Auto Trait Implementations§
impl Freeze for Trigger
impl RefUnwindSafe for Trigger
impl Send for Trigger
impl Sync for Trigger
impl Unpin for Trigger
impl UnsafeUnpin for Trigger
impl UnwindSafe for Trigger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more