Function create_app

Source
pub async fn create_app(
    pool: &Pool<MySql>,
    name: &str,
    org_id: i64,
    git_repo: Option<&str>,
    git_branch: Option<&str>,
    container_image_url: Option<&str>,
    region_id: Option<i64>,
) -> Result<App>
Expand description

Creates a new application in the database.

This function inserts a new application record with the provided parameters. It handles both required fields (name, organization ID) and optional fields. The application is created with maintenance mode disabled by default.

§Arguments

  • pool - Database connection pool for executing the query
  • name - Name of the application
  • org_id - Organization ID that the application belongs to
  • git_repo - Optional URL of the Git repository for the application
  • git_branch - Optional branch name in the Git repository
  • container_image_url - Optional URL for a container image
  • region_id - Optional ID of the deployment region

§Returns

  • Ok(App) - Successfully created application, including database-assigned fields
  • Err(anyhow::Error) - Failed to create application

§Transaction Handling

This function uses a database transaction to ensure atomicity of the operation. If any part of the operation fails, the entire operation is rolled back.