backbone-mailing 0.4.0

Email marketing — mass-mail engine: audiences, subscriptions, hand-set mailing lifecycle, seeded A/B testing, per-recipient traces, cycle-44 bridge targets (Odoo mass_mailing port)
//! Database seeders for the mailing module
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! This module provides seed data for initial database setup.
//! Seeders can be run via the seeder binary or CLI.

use anyhow::Result;
use async_trait::async_trait;
use sqlx::PgPool;

mod mailing_ab_test_seeder;
mod mailing_audience_seeder;
mod mailing_contact_seeder;
mod mailing_subscription_seeder;
mod opt_out_reason_seeder;
mod mailing_seeder;
mod mailing_trace_seeder;
mod mailing_filter_seeder;

pub use mailing_ab_test_seeder::SeedMailingAbTestSeeder;
pub use mailing_audience_seeder::SeedMailingAudienceSeeder;
pub use mailing_contact_seeder::SeedMailingContactSeeder;
pub use mailing_subscription_seeder::SeedMailingSubscriptionSeeder;
pub use opt_out_reason_seeder::SeedOptOutReasonSeeder;
pub use mailing_seeder::SeedMailingSeeder;
pub use mailing_trace_seeder::SeedMailingTraceSeeder;
pub use mailing_filter_seeder::SeedMailingFilterSeeder;

// ============================================================================
// SEEDER TRAIT
// ============================================================================

/// Trait for database seeders
#[async_trait]
pub trait Seeder {
    /// Get the name of this seeder
    fn name(&self) -> &'static str;

    /// Get the order in which this seeder should run
    fn order(&self) -> i32;

    /// Check if this seeder should run (e.g., check if data already exists)
    async fn should_run(&self, pool: &PgPool) -> Result<bool>;

    /// Run the seeder
    async fn run(&self, pool: &PgPool) -> Result<()>;

    /// Rollback the seeder (optional)
    async fn rollback(&self, _pool: &PgPool) -> Result<()> {
        Ok(())
    }
}

// ============================================================================
// SEEDER TYPE
// ============================================================================

/// Type of seeder
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SeederType {
    /// Reference data (required for application to function)
    Reference,
    /// Initial production data
    Production,
    /// Development/testing data
    Development,
    /// Test data (for automated tests)
    Test,
}

// ============================================================================
// CUSTOM SEEDERS
// ============================================================================

// <<< CUSTOM SEEDERS START >>>
// Add custom seeders here
// <<< CUSTOM SEEDERS END >>>