schemas_v1_db_queries_deployment - OmniCloudOrg/OmniOrchestrator GitHub Wiki

deployment (src/schemas/v1/db/queries)

Path: src/schemas/v1/db/queries/deployment.rs

Table of Contents

Public Items

async fn list_deployments

Definition

pub async fn list_deployments(pool: &Pool<MySql>, page: i64, per_page: i64) -> anyhow::Result<Vec<Deployment>> {
    println!("Attempting to fetch deployments from database...");

Documentation

Retrieves a paginated list of deployments from the database.

async fn count_deployments

Definition

pub async fn count_deployments(pool: &Pool<MySql>) -> anyhow::Result<i64> {
    let count = sqlx::query_scalar::<_, i64>("SELECT COUNT(*) FROM deployments")
        .fetch_one(pool)
        .await
        .context("Failed to count deployments")?;

Documentation

Counts the total number of deployments in the database.

async fn get_deployment_by_id

Definition

pub async fn get_deployment_by_id(pool: &Pool<MySql>, id: i64) -> anyhow::Result<Deployment> {
    let deployment = sqlx::query_as::<_, Deployment>("SELECT * FROM deployments WHERE id = ?")
        .bind(id)
        .fetch_one(pool)
        .await
        .context("Failed to fetch deployment")?;

Documentation

Retrieves a specific deployment by its unique identifier.

async fn list_deployments_by_app

Definition

pub async fn list_deployments_by_app(
    pool: &Pool<MySql>, 
    app_id: i64, 
    page: i64, 
    per_page: i64
) -> anyhow::Result<Vec<Deployment>> {
    // ... function body
}

Documentation

Retrieves all deployments for a specific application with pagination.

async fn count_deployments_by_app

Definition

pub async fn count_deployments_by_app(pool: &Pool<MySql>, app_id: i64) -> anyhow::Result<i64> {
    let count = sqlx::query_scalar::<_, i64>(
        "SELECT COUNT(*) FROM deployments WHERE app_id = ?"
    )
    .bind(app_id)
    .fetch_one(pool)
    .await
    .context("Failed to count deployments by app_id")?;

Documentation

Counts the number of deployments for a specific application.

async fn create_deployment

Definition

pub async fn create_deployment(
    pool: &Pool<MySql>,
    app_id: i64,
    build_id: i64,
    version: &str,
    deployment_strategy: &str,
    previous_deployment_id: Option<i64>,
    canary_percentage: Option<i64>,
    environment_variables: Option<serde_json::Value>,
    annotations: Option<serde_json::Value>,
    labels: Option<serde_json::Value>,
    created_by: Option<i64>,
) -> anyhow::Result<Deployment> {
    // ... function body
}

Documentation

Creates a new deployment in the database.

async fn update_deployment_status

Definition

pub async fn update_deployment_status(
    pool: &Pool<MySql>,
    id: i64,
    status: &str,
    error_message: Option<&str>,
) -> anyhow::Result<Deployment> {
    // ... function body
}

Documentation

Updates the status of an existing deployment.

async fn delete_deployment

Definition

pub async fn delete_deployment(pool: &Pool<MySql>, id: i64) -> anyhow::Result<()> {
    let mut tx = pool.begin().await?;

Documentation

Deletes a deployment from the database.

⚠️ **GitHub.com Fallback** ⚠️