backbone-events 0.5.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)
//! LeadProvenance seeder
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! Seeds initial LeadProvenance data into the database.

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

use super::Seeder;

// ============================================================================
// LEADPROVENANCE SEEDER
// ============================================================================

/// Seeder for lead_provenance
pub struct SeedLeadProvenanceSeeder;

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

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

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

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

    async fn should_run(&self, pool: &PgPool) -> Result<bool> {
        // Check if event.lead_provenances table has any data
        let count: (i64,) = sqlx::query_as("SELECT COUNT(*) FROM event.lead_provenances")
            .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_provenance_seed.sql");
        sqlx::raw_sql(sql).execute(pool).await?;
        Ok(())
    }

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

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

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