schemas_v1_db_queries_deployment - OmniCloudOrg/OmniOrchestrator GitHub Wiki
Path: src/schemas/v1/db/queries/deployment.rs
- async fn list_deployments
- async fn count_deployments
- async fn get_deployment_by_id
- async fn list_deployments_by_app
- async fn count_deployments_by_app
- async fn create_deployment
- async fn update_deployment_status
- async fn delete_deployment
pub async fn list_deployments(pool: &Pool<MySql>, page: i64, per_page: i64) -> anyhow::Result<Vec<Deployment>> {
println!("Attempting to fetch deployments from database...");
Retrieves a paginated list of deployments from the database.
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")?;
Counts the total number of deployments in the database.
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")?;
Retrieves a specific deployment by its unique identifier.
pub async fn list_deployments_by_app(
pool: &Pool<MySql>,
app_id: i64,
page: i64,
per_page: i64
) -> anyhow::Result<Vec<Deployment>> {
// ... function body
}
Retrieves all deployments for a specific application with pagination.
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")?;
Counts the number of deployments for a specific application.
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
}
Creates a new deployment in the database.
pub async fn update_deployment_status(
pool: &Pool<MySql>,
id: i64,
status: &str,
error_message: Option<&str>,
) -> anyhow::Result<Deployment> {
// ... function body
}
Updates the status of an existing deployment.
pub async fn delete_deployment(pool: &Pool<MySql>, id: i64) -> anyhow::Result<()> {
let mut tx = pool.begin().await?;
Deletes a deployment from the database.