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

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

use super::Seeder;

// ============================================================================
// REGISTRATIONANSWER SEEDER
// ============================================================================

/// Seeder for registration_answer
pub struct SeedRegistrationAnswerSeeder;

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

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

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

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

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

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

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

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