Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions databases/curriculum/src/bin/cdb-migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//! Env: `CDB_MIGRATOR_URL`, naming the database (`.../curriculum`), never a `db/branch` revision.
use std::{process::ExitCode, time::Duration};

use cdb::migrations;

/// Bounds the whole run: waiting for another run's lock, then applying and merging. The deploy
/// Action's MIGRATE_SECONDS must stay above this plus the image pull. A run cut short ends its
/// session, which releases the lock; anything it left is on the scratch branch, which the next run
Expand All @@ -24,13 +26,13 @@ async fn main() -> ExitCode {
return ExitCode::from(2);
};

match tokio::time::timeout(TIMEOUT, cdb::migrate(&url)).await {
match tokio::time::timeout(TIMEOUT, migrations::migrate(&url)).await {
Ok(Ok(applied)) if applied.is_empty() => {
println!("cDb up to date");
ExitCode::SUCCESS
}
Ok(Ok(applied)) => {
println!("cDb migrations applied to {}: {applied:?}", cdb::DEV);
println!("cDb migrations applied to {}: {applied:?}", migrations::DEV);
ExitCode::SUCCESS
}
Ok(Err(err)) => {
Expand Down
20 changes: 20 additions & 0 deletions databases/curriculum/src/edd/exams.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use crate::Database;

pub async fn create(
db: &Database,
id: &str,
slug: &str,
title: &str,
instructions: &str,
) -> sqlx::Result<()> {
sqlx::query(
"INSERT INTO exams (id, slug, title, instructions, status) VALUES (?, ?, ?, ?, 'disabled')",
)
.bind(id)
.bind(slug)
.bind(title)
.bind(instructions)
.execute(&db.pool)
.await?;
Ok(())
}
2 changes: 2 additions & 0 deletions databases/curriculum/src/edd/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
//! Schema `edd`: eDd's tables. aAPI has no access.

pub mod exams;
Loading