Database Schema
Dictumal uses PostgreSQL with Prisma ORM. This page reflects the current schema in prisma/schema.prisma.
Enums
| Enum | Values |
|---|---|
ClauseType | VALUE, PRINCIPLE, POLICY, CONSTRAINT |
ClauseStatus | DRAFT, PROPOSED, RATIFIED, ARCHIVED |
Stance | SUPPORTING, CONTRADICTING, NEUTRAL |
GroupRole | ADMIN, AUTHOR, VOTER, REVIEWER, OBSERVER |
VoteChoice | AGREE, DISAGREE, STAND_ASIDE, BLOCK |
ProposalStatus | DRAFT, DISCUSSION, VOTING, RATIFIED, REJECTED, WITHDRAWN |
ChatClauseRelation | ORIGIN, AMENDMENT, REFERENCE |
DeploymentStatus | PROVISIONING, CONFIGURING, ACTIVE, ERROR, DESTROYING, DESTROYED |
Models
User
- Scalars:
id,email(unique),name?,passwordHash?,createdAt,updatedAt. - Relations:
constitutions,chatSessions,deployments,memberships,proposals,votes,comments.
Constitution
- Scalars:
id,title,description?,authorId,groupId?,isTemplate,templateName?,forkedFromId?,createdAt,updatedAt. - Relations:
author,clauses,chatSessions,deployments,versions,group?,forkedFrom?,forks.
Clause
- Scalars:
id,constitutionId,type,naturalLanguage,rationale?,irData,derivedFromId?,draftConversation?,status,order,createdAt,updatedAt. - Relations:
constitution,derivedFrom?,derivedClauses,research,chatSessionLinks,proposals.
ResearchResult
- Scalars:
id,clauseId,title,url,snippet,stance,synthesis,source,searchQuery,createdAt. - Relation:
clause(cascade delete).
Version
- Scalars:
id,constitutionId,snapshot,message?,branch,parentVersionId?,createdAt. - Relations:
constitution,parentVersion?,childVersions.
Group
- Scalars:
id,name,description?,inviteCode(unique),createdAt,updatedAt. - Relations:
members,constitutions.
GroupMember
- Scalars:
id,groupId,userId,role,joinedAt. - Relations:
group(cascade delete),user. - Constraint: unique composite key on
(groupId, userId).
Proposal
- Scalars:
id,clauseId,authorId,status,statementOfPurpose?,votingDeadline?,createdAt,updatedAt. - Relations:
clause(cascade delete),author,votes,comments.
Vote
- Scalars:
id,proposalId,userId,choice,reason?,createdAt. - Relations:
proposal(cascade delete),user. - Constraint: unique composite key on
(proposalId, userId).
Comment
- Scalars:
id,proposalId,authorId,content,parentId?,createdAt. - Relations:
proposal(cascade delete),author,parent?,replies.
ChatSession
- Scalars:
id,constitutionId,userId,mode,messages,createdAt. - Relations:
constitution(cascade delete),user,clauseLinks.
ChatSessionClause
- Scalars:
id,chatSessionId,clauseId,relation,createdAt. - Relations:
chatSession(cascade delete),clause(cascade delete). - Constraint: unique composite key on
(chatSessionId, clauseId, relation).
Deployment
- Scalars:
id,constitutionId,userId,provider,dropletId?,ipAddress?,region,size,vncPassword?,status,errorMessage?,createdAt,updatedAt. - Relations:
constitution(cascade delete),user.
Notes
- Most content entities use
@default(cuid())for primary keys. - Deleting a constitution cascades to clauses, chat sessions, versions, and deployments.
- Group membership, votes, and chat clause links use composite unique constraints to prevent duplicate records.