backbone-digest 0.3.0

KPI digests — the periodic KPI-email engine: a declarative name-keyed KPI registry other modules extend, per-recipient fenced rendering with declared (never row-count) KPI drops, the anti-spam slowdown ladder, a shared tips carousel, and a daily plain-pull cron whose due-date column is the queue (Odoo digest port)
//! DigestTipUser seeder
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! Seeds initial DigestTipUser data into the database.

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

use super::Seeder;

// ============================================================================
// DIGESTTIPUSER SEEDER
// ============================================================================

/// Seeder for digest_tip_user
pub struct SeedDigestTipUserSeeder;

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

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

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

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

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

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

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

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