Skip to content
Venue booking & governance

moderator_elections

The election itself + its lifecycle (G801). One active (non-closed) election per profile is enforced in the router.

Columns

ColumnTypeNullDefaultKeys
iduuid nogen_random_uuid()
PK
profile_iduuid no—
statustext
nominationsvotingclosed
no"nominations"
term_startdate yes—
term_enddate yes—
nominations_open_attimestamp yesnow()
voting_open_attimestamp yes—
closes_attimestamp yes—
closed_attimestamp yes—
winner_candidate_iduuid yes—
created_attimestamp yesnow()

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

Used by

Code that reads or writes this table, found by static analysis of the tRPC routers and API handlers (including helpers they call).

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.