Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

985 B
Raw Blame
use anyhow::{Context, Result};
use sqlx::postgres::PgPool;

use crate::cli::{CleanupArgs, SeedArgs};
use crate::seed;

pub async fn run(args: SeedArgs) -> Result<()> {
    let pool = PgPool::connect(&args.persons_db_url)
        .await
        .context("connecting to persons DB")?;

    let ids = seed::seed_persons(&pool, &args.pg_target_table, args.team_id, args.count).await?;

    println!("Seeded {} persons for team {}", ids.len(), args.team_id);
    println!();
    println!(
        "  --team-id {} --person-ids {}",
        args.team_id,
        ids.iter().map(i64::to_string).collect::<Vec<_>>().join(",")
    );
    Ok(())
}

pub async fn run_cleanup(args: CleanupArgs) -> Result<()> {
    let pool = PgPool::connect(&args.persons_db_url)
        .await
        .context("connecting to persons DB")?;

    let persons = seed::cleanup_team(&pool, &args.pg_target_table, args.team_id).await?;
    println!("Deleted {persons} persons for team {}", args.team_id);
    Ok(())
}