Skip to main content

schema_sql_generator/common/
trigger_generator.rs

1use crate::common::generator_context::GeneratorContext;
2use schema_model::model::table::Table;
3
4pub trait TriggerGenerator {
5    fn output_triggers(&self);
6
7    /// Regenerates the full (idempotent) trigger set for a single table - used by the
8    /// migration generator when only that table's custom triggers changed, so it doesn't
9    /// have to re-derive the combined relation/aggregation/custom-trigger logic that
10    /// `output_triggers` already knows how to produce. No-op by default (SQLite has no
11    /// trigger support here, matching `output_triggers`).
12    fn output_triggers_for_table(&self, table: &Table);
13}
14
15pub struct DefaultTriggerGenerator {
16    context: GeneratorContext,
17}
18
19impl DefaultTriggerGenerator {
20    pub fn new(context: GeneratorContext) -> Self {
21        Self {
22            context,
23        }
24    }
25
26    pub fn context(&self) -> &GeneratorContext {
27        &self.context
28    }
29}
30
31impl TriggerGenerator for DefaultTriggerGenerator {
32    fn output_triggers(&self) {
33    }
34
35    fn output_triggers_for_table(&self, _table: &Table) {
36    }
37}