Files
clawmates/crates/tc-db/src/repo/workspaces.rs
T
Omar SobhandClaude Fable 5 0afb359183 P0: workspace scaffold, CI gates, tc-domain, tc-config, tc-db vs real Postgres
- Cargo workspace with 1250-line and no-placeholder CI gates wired first
- tc-domain: id newtypes, SessionKey codec (proptest round-trip), Role,
  GatedCategory (spec §15), AccessPolicy, core entities
- tc-config: figment TOML+env config, DeployTarget/provider/auth selection
  with semantic validation
- migrations/0001: full spec §14 schema incl. DB-enforced append-only audit_log
- tc-db: compile-time-checked sqlx repos (workspaces, users, agents+policies,
  credits, audit) with committed .sqlx offline metadata
- tc-testkit: per-test real-Postgres databases (testcontainers or
  TC_TEST_DATABASE_URL), embedded migrations

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-06-09 22:25:47 -05:00

31 lines
734 B
Rust

use sqlx::PgPool;
use tc_domain::{Workspace, WorkspaceId};
use crate::DbError;
pub async fn insert(pool: &PgPool, workspace: &Workspace) -> Result<(), DbError> {
sqlx::query!(
"INSERT INTO workspaces (id, name, plan) VALUES ($1, $2, $3)",
workspace.id.as_uuid(),
workspace.name,
workspace.plan,
)
.execute(pool)
.await?;
Ok(())
}
pub async fn get(pool: &PgPool, id: WorkspaceId) -> Result<Workspace, DbError> {
let row = sqlx::query!(
"SELECT id, name, plan FROM workspaces WHERE id = $1",
id.as_uuid(),
)
.fetch_one(pool)
.await?;
Ok(Workspace {
id: WorkspaceId::from(row.id),
name: row.name,
plan: row.plan,
})
}