Venue booking & governance
moderator_elections
The election itself + its lifecycle (G801). One active (non-closed) election per profile is enforced in the router.
Columns
| Column | Type | Null | Default | Keys |
|---|---|---|---|---|
| id | uuid | no | gen_random_uuid() | PK |
| profile_id | uuid | no | — | |
| status | text nominationsvotingclosed | no | "nominations" | |
| term_start | date | yes | — | |
| term_end | date | yes | — | |
| nominations_open_at | timestamp | yes | now() | |
| voting_open_at | timestamp | yes | — | |
| closes_at | timestamp | yes | — | |
| closed_at | timestamp | yes | — | |
| winner_candidate_id | uuid | yes | — | |
| created_at | timestamp | yes | now() |
Value lists come from .$type<'a' | 'b'>() in the schema — enforced in TypeScript only, not by the database.
Keys, constraints & indexes
Unique
None besides the primary key.
Indexes
- (profile_id)moderator_elections_profile_idx
Foreign keys
- profile_id → profiles.id on delete no action
Referenced by
- election_candidates (election_id)
- election_vote_history (election_id)
- election_votes (election_id)
- guideline_versions (election_id)
Used by
Code that reads or writes this table, found by static analysis of the tRPC routers and API handlers (including helpers they call).
tRPC procedures
REST & webhooks
- ANY /mcp
- ANY /mcp/public
Relations
Rendering diagram…
Diagram source
erDiagram
election_candidates {
uuid id PK
uuid election_id FK
uuid dancer_id FK
}
election_vote_history {
uuid id PK
uuid election_id FK
uuid voter_dancer_id FK
}
election_votes {
uuid id PK
uuid election_id FK
uuid voter_dancer_id FK
uuid candidate_id FK
}
guideline_versions {
uuid id PK
uuid profile_id FK
uuid election_id FK
uuid moderator_dancer_id FK
}
moderator_elections {
uuid id PK
uuid profile_id FK
}
profiles {
uuid id PK
text username UK
}
moderator_elections ||--o{ election_candidates : "election_id"
moderator_elections ||--o{ election_vote_history : "election_id"
moderator_elections ||--o{ election_votes : "election_id"
election_candidates ||--o{ election_votes : "candidate_id"
profiles ||--o{ guideline_versions : "profile_id"
moderator_elections |o--o{ guideline_versions : "election_id"
profiles ||--o{ moderator_elections : "profile_id" Defined at server/database/schema.ts:594 as moderatorElections.