backbone-integrations 0.6.0

Integration registry: connectors, integration accounts and an idempotent inbound event lane, with one OAuth flow (HMAC-bound state, PKCE)
Documentation
//! IntegrationEvent seeder
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! Seeds initial IntegrationEvent data into the database.

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

use super::Seeder;

// ============================================================================
// INTEGRATIONEVENT SEEDER
// ============================================================================

/// Seeder for integration_event
pub struct SeedIntegrationEventSeeder;

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

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

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

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

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

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

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

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