Function create_build

Source
pub async fn create_build(
    pool: &Pool<MySql>,
    app_id: i64,
    git_commit: &str,
    git_branch: &str,
    git_repo: &str,
    status: &str,
    build_log: &str,
) -> Result<Vec<Build>>
Expand description

Creates a new build record in the database.

This function inserts a new build entry with the provided parameters. It’s typically called when a new build process is initiated for an application.

§Arguments

  • pool - Database connection pool for executing the query
  • app_id - Identifier of the application this build belongs to
  • git_commit - Git commit hash or identifier for this build
  • git_branch - Git branch name used for this build
  • git_repo - Git repository URL or identifier
  • status - Initial status of the build (e.g., “pending”, “in_progress”)
  • build_log - Initial build log content (may be empty or contain setup information)

§Returns

  • Ok(Vec<Build>) - Successfully created build record(s)
  • Err(anyhow::Error) - Failed to create build record

§Note

The function returns a vector of builds, which is unusual for a creation operation that typically returns a single record. This may be due to specific implementation requirements or to accommodate batch creation scenarios.

§Important

This function doesn’t take a transaction parameter, so it commits changes immediately. For operations that need to be part of a larger transaction, consider enhancing this function to accept a transaction parameter.