Files
PiCloud/crates/shared/src/project.rs
MechaCat02 ba97c35aaf feat(projects): projects table + owner_project FK; ProjectId/Project types
First commit of §7 multi-repo ownership. A 'project' is a repo-root that
declaratively manages a slice of the shared group tree; each group node is
owned by exactly one project (single-owner-per-node). This lands the registry
+ shared types and wires the inert 0047 `owner_project` seam — no behavior
change yet (claim logic is the next commit).

- migration 0066: `projects` table (UUID pk, unique slug, name, created_by →
  admin_users ON DELETE SET NULL); `groups.owner_project` gains its FK →
  projects(id) ON DELETE SET NULL (un-claim, never cascade-destroy a tree) +
  an index.
- shared: `ProjectId` (id_type! macro) + `Project` struct; `Group` gains
  `owner_project: Option<ProjectId>`.
- group_repo: GROUP_COLS + the ancestors recursive-CTE term now carry
  `owner_project`, so `ancestors()` surfaces ownership for the nearest-claimed
  fold; GroupRow + From updated.
- schema snapshot re-blessed; /version schema assertion 65 → 66.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 20:01:57 +02:00

28 lines
1.0 KiB
Rust

//! Projects: the §7 multi-repo ownership registry.
//!
//! A project is a repo-root that declaratively MANAGES a slice of the shared
//! group tree. Each group node is owned by exactly one project (recorded in
//! `groups.owner_project`); apps inherit ownership from their nearest claimed
//! ancestor group. Identity is a committed `[project] slug` — stable across
//! clones; the server assigns the UUID.
//!
//! See docs/design/groups-and-project-tool.md §7.
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use crate::{AdminUserId, ProjectId};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Project {
pub id: ProjectId,
/// Instance-global identity, declared in the repo's root manifest and
/// frozen at registration.
pub slug: String,
pub name: String,
/// The admin who first registered the project (`None` once their account
/// is deleted — the FK is `ON DELETE SET NULL`).
pub created_by: Option<AdminUserId>,
pub created_at: DateTime<Utc>,
}