Skip to main content

backbone_integrations/seeders/
integration_connector_seeder.rs

1//! IntegrationConnector seeder
2//!
3//! Generated by metaphor-schema. Do not edit manually.
4//!
5//! Seeds initial IntegrationConnector data into the database.
6
7use anyhow::Result;
8use async_trait::async_trait;
9use sqlx::PgPool;
10
11use super::Seeder;
12
13// ============================================================================
14// INTEGRATIONCONNECTOR SEEDER
15// ============================================================================
16
17/// Seeder for integration_connector
18pub struct SeedIntegrationConnectorSeeder;
19
20impl SeedIntegrationConnectorSeeder {
21    pub fn new() -> Self {
22        Self
23    }
24}
25
26impl Default for SeedIntegrationConnectorSeeder {
27    fn default() -> Self {
28        Self::new()
29    }
30}
31
32#[async_trait]
33impl Seeder for SeedIntegrationConnectorSeeder {
34    fn name(&self) -> &'static str {
35        "SeedIntegrationConnectorSeeder"
36    }
37
38    fn order(&self) -> i32 {
39        1
40    }
41
42    async fn should_run(&self, pool: &PgPool) -> Result<bool> {
43        // Check if integrations.integration_connectors table has any data
44        let count: (i64,) = sqlx::query_as("SELECT COUNT(*) FROM integrations.integration_connectors")
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_connector_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_connectors")
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 >>>