Skip to main content

backbone_integrations/seeders/
integration_event_seeder.rs

1//! IntegrationEvent seeder
2//!
3//! Generated by metaphor-schema. Do not edit manually.
4//!
5//! Seeds initial IntegrationEvent data into the database.
6
7use anyhow::Result;
8use async_trait::async_trait;
9use sqlx::PgPool;
10
11use super::Seeder;
12
13// ============================================================================
14// INTEGRATIONEVENT SEEDER
15// ============================================================================
16
17/// Seeder for integration_event
18pub struct SeedIntegrationEventSeeder;
19
20impl SeedIntegrationEventSeeder {
21    pub fn new() -> Self {
22        Self
23    }
24}
25
26impl Default for SeedIntegrationEventSeeder {
27    fn default() -> Self {
28        Self::new()
29    }
30}
31
32#[async_trait]
33impl Seeder for SeedIntegrationEventSeeder {
34    fn name(&self) -> &'static str {
35        "SeedIntegrationEventSeeder"
36    }
37
38    fn order(&self) -> i32 {
39        2
40    }
41
42    async fn should_run(&self, pool: &PgPool) -> Result<bool> {
43        // Check if integrations.integration_events table has any data
44        let count: (i64,) = sqlx::query_as("SELECT COUNT(*) FROM integrations.integration_events")
45            .fetch_one(pool)
46            .await?;
47        Ok(count.0 == 0)
48    }
49
50    async fn run(&self, pool: &PgPool) -> Result<()> {
51        // Run the SQL seed file
52        let sql = include_str!("../../migrations/seeds/integration_event_seed.sql");
53        sqlx::raw_sql(sql).execute(pool).await?;
54        Ok(())
55    }
56
57    async fn rollback(&self, pool: &PgPool) -> Result<()> {
58        sqlx::query("DELETE FROM integrations.integration_events")
59            .execute(pool)
60            .await?;
61        Ok(())
62    }
63}
64
65// ============================================================================
66// CUSTOM SEED DATA
67// ============================================================================
68
69// <<< CUSTOM SEED DATA START >>>
70// Add custom seed data methods here
71// <<< CUSTOM SEED DATA END >>>