backbone-events 0.4.0

Events core + the sale/booth/crm/sms/desk overlay — registrations under one authoritative seat counter, the sale seam (order-minted registrations, forward-only paid heal, SO-cancel mirror cascade), booth bookings with the DB exclusivity wall, closed-vocabulary lead rules through a host sink port, the dual-channel (mail/sms) self-arming scheduler, and the exact-match desk verb (Odoo event port, core + overlay)
//! LeadRule seeder
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! Seeds initial LeadRule data into the database.

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

use super::Seeder;

// ============================================================================
// LEADRULE SEEDER
// ============================================================================

/// Seeder for lead_rule
pub struct SeedLeadRuleSeeder;

impl SeedLeadRuleSeeder {
    pub fn new() -> Self {
        Self
    }
}

impl Default for SeedLeadRuleSeeder {
    fn default() -> Self {
        Self::new()
    }
}

#[async_trait]
impl Seeder for SeedLeadRuleSeeder {
    fn name(&self) -> &'static str {
        "SeedLeadRuleSeeder"
    }

    fn order(&self) -> i32 {
        11
    }

    async fn should_run(&self, pool: &PgPool) -> Result<bool> {
        // Check if event.lead_rules table has any data
        let count: (i64,) = sqlx::query_as("SELECT COUNT(*) FROM event.lead_rules")
            .fetch_one(pool)
            .await?;
        Ok(count.0 == 0)
    }

    async fn run(&self, pool: &PgPool) -> Result<()> {
        // Run the SQL seed file
        let sql = include_str!("../../migrations/seeds/lead_rule_seed.sql");
        sqlx::raw_sql(sql).execute(pool).await?;
        Ok(())
    }

    async fn rollback(&self, pool: &PgPool) -> Result<()> {
        sqlx::query("DELETE FROM event.lead_rules")
            .execute(pool)
            .await?;
        Ok(())
    }
}

// ============================================================================
// CUSTOM SEED DATA
// ============================================================================

// <<< CUSTOM SEED DATA START >>>
// Add custom seed data methods here
// <<< CUSTOM SEED DATA END >>>