We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

models 11.4 KB
Newer Older
David L. L. Thomas's avatar
David L. L. Thomas committed
1 2 3
Account
    balance Milray

David L. L. Thomas's avatar
David L. L. Thomas committed
4 5 6 7
Payday
    date UTCTime


David L. L. Thomas's avatar
David L. L. Thomas committed
8 9 10 11 12 13
Transaction
    ts UTCTime

    credit AccountId Maybe
    debit AccountId Maybe

David L. L. Thomas's avatar
David L. L. Thomas committed
14 15
    payday PaydayId Maybe

David L. L. Thomas's avatar
David L. L. Thomas committed
16 17 18 19 20 21 22
    amount Milray

    reason Text
    info Text Maybe

User
    ident Text
wolftune's avatar
wolftune committed
23
    createdTs UTCTime Maybe
David L. L. Thomas's avatar
Login  
David L. L. Thomas committed
24 25
    hash Text Maybe
    salt Text Maybe
David L. L. Thomas's avatar
David L. L. Thomas committed
26 27 28 29 30
    name Text Maybe
    account AccountId
    avatar Text Maybe
    blurb Markdown Maybe
    statement Markdown Maybe
31
    ircNick Text Maybe
32
    readMessages UTCTime default=now() -- The last time the user visited /messages
33
    readApplications UTCTime default=now()
34
    established Established default='EstUnestablished'
David L. L. Thomas's avatar
David L. L. Thomas committed
35 36
    UniqueUser ident
    UniqueUserAccount account
Mitchell Rosen's avatar
Mitchell Rosen committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50
    deriving Show Typeable

-- A single message preference. If some MessageType does not appear
-- in any row for a particular user, that means the user does not
-- wish to be notified of those messages.
--
-- Messages that "must" be delivered (e.g. administrative messages
-- directly from Snowdrift) don't need an entry in this table, as
-- the code that sends such messages needn't query it.
UserMessagePref
    user UserId
    type MessageType
    delivery MessageDelivery
    UniqueUserMessagePref user type
51

52 53 54 55 56 57 58 59 60 61 62 63
-- User-watching-project relation
UserWatchingProject
    user UserId
    project ProjectId
    UniqueUserWatchingProject user project

-- TODO(mitchell) is this used?
UserSetting
    user UserId
    setting UserSettingName
    value String

64 65 66 67 68 69
ViewTime
    user UserId
    project ProjectId
    type ViewType
    time UTCTime default=now()
    UniqueViewTimeUserProjectType user project type
David L. L. Thomas's avatar
David L. L. Thomas committed
70

Mitchell Rosen's avatar
Mitchell Rosen committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84
-- A viewing of a single comment. The existence of this of a row here indicates
-- the comment has been viewed by the user; the absence indicates it hasnt.
ViewComment
    user UserId
    comment CommentId
    UniqueViewComment user comment

-- A viewing of a single wiki page edit. The existence of this of a row here indicates
-- the edit has been viewed by the user; the absence indicates it hasnt.
ViewWikiEdit
    user UserId
    edit WikiEditId
    UniqueViewWikiEdit user edit

David L. L. Thomas's avatar
David L. L. Thomas committed
85 86 87
Project
    createdTs UTCTime
    name Text
88
    handle Text
David L. L. Thomas's avatar
David L. L. Thomas committed
89 90 91
    description Markdown
    account AccountId
    shareValue Milray
David L. L. Thomas's avatar
David L. L. Thomas committed
92
    lastPayday PaydayId Maybe
93
    githubRepo Text Maybe
David L. L. Thomas's avatar
David L. L. Thomas committed
94
    UniqueProjectAccount account
95
    UniqueProjectHandle handle
96
    deriving Eq Show
David L. L. Thomas's avatar
David L. L. Thomas committed
97

David L. L. Thomas's avatar
Bugfix  
David L. L. Thomas committed
98 99 100
ProjectBlog
    time UTCTime
    title Text
101
    handle Text
David L. L. Thomas's avatar
Bugfix  
David L. L. Thomas committed
102
    user UserId
103
    project ProjectId
104
    discussion DiscussionId
105 106
    topContent Markdown
    bottomContent Markdown Maybe
107
    UniqueProjectBlogPost project handle
108
    deriving Show
David L. L. Thomas's avatar
Bugfix  
David L. L. Thomas committed
109

110
ProjectUserRole
111
    project ProjectId
112
    user UserId
113
    role Role
114
    UniqueProjectUserRole project user role
115
    deriving Show
David L. L. Thomas's avatar
David L. L. Thomas committed
116 117 118 119 120 121 122 123 124 125 126 127

ProjectUpdate
    updatedTs UTCTime
    project ProjectId
    author UserId
    description MarkdownDiff

ProjectLastUpdate
    project ProjectId
    update ProjectUpdateId
    UniqueProjectLastUpdate project

128 129 130
-- Parts of Pledge are duplicated in EventDeletedPledge.
-- If you modify Pledge, be sure to (possibly) modify
-- EventDeletedPledge as well!
David L. L. Thomas's avatar
David L. L. Thomas committed
131
Pledge
132
    createdTs UTCTime default=now()
David L. L. Thomas's avatar
David L. L. Thomas committed
133 134 135 136 137 138 139 140
    user UserId
    project ProjectId
    shares Int64
    fundedShares Int64
    UniquePledge user project

Invite
    createdTs UTCTime
141
    project ProjectId
David L. L. Thomas's avatar
David L. L. Thomas committed
142 143 144 145 146 147 148 149 150
    code Text
    user UserId
    role Role
    tag Text
    redeemed Bool
    redeemedTs UTCTime Maybe
    redeemedBy UserId Maybe
    UniqueInvite code

Kim Hoff's avatar
Kim Hoff committed
151
VolunteerApplication
David L. L. Thomas's avatar
David L. L. Thomas committed
152
    createdTs UTCTime
153
    project ProjectId
David L. L. Thomas's avatar
David L. L. Thomas committed
154 155 156 157
    user UserId
    name Text
    email Text
    otherContactInfo Text Maybe
158 159 160
    website Text Maybe
    location Text Maybe
    experience Textarea Maybe
David L. L. Thomas's avatar
David L. L. Thomas committed
161 162
    comments Textarea Maybe

163 164 165 166 167 168
Interest
    description Text

VolunteerInterest
    volunteer VolunteerApplicationId
    interest InterestId
David L. L. Thomas's avatar
David L. L. Thomas committed
169

170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
-- Many valid permutations here:
--
-- +---------------------+-----------------------------------------------------+
-- | fromUser    Nothing | Arbitrary "alert" message/notification, not from    |
-- | fromProject Nothing | any particular user or project (such as "a user has |
-- | toProject   Nothing | replied to one of your comments").                  |
-- +---------------------+-----------------------------------------------------+
-- | fromUser    Nothing | Anonymous message sent to a project (feedback).     |
-- | fromProject Nothing |                                                     |
-- | toProject   Just    |                                                     |
-- +---------------------+-----------------------------------------------------+
-- | fromUser    Nothing | Project-to-user message.                            |
-- | fromProject Just    |                                                     |
-- | toProject   Nothing |                                                     |
-- +---------------------+-----------------------------------------------------+
-- | fromUser    Nothing | Project-to-project message.                         |
-- | fromProject Just    |                                                     |
-- | toProject   Just    |                                                     |
-- +---------------------+-----------------------------------------------------+
-- | fromUser    Just    | User-to-user message.                               |
-- | fromProject Nothing |                                                     |
-- | toProject   Nothing |                                                     |
-- +---------------------+-----------------------------------------------------+
-- | fromUser    Just    | User-to-project message.                            |
-- | fromProject Nothing |                                                     |
-- | toProject   Just    |                                                     |
-- +---------------------+-----------------------------------------------------+
-- | fromUser    Just    | User-to-user message, on behalf of a project.       |
-- | fromProject Just    |                                                     |
-- | toProject   Nothing |                                                     |
-- +---------------------+-----------------------------------------------------+
-- | fromUser    Just    | User-to-project message, on behalf of a project.    |
-- | fromProject Just    |                                                     |
-- | toProject   Just    |                                                     |
-- +---------------------+-----------------------------------------------------+
David L. L. Thomas's avatar
David L. L. Thomas committed
205 206
Message
    createdTs UTCTime
207 208 209 210 211
    type MessageType
    fromUser UserId Maybe
    fromProject ProjectId Maybe
    toUser UserId
    toProject ProjectId Maybe
David L. L. Thomas's avatar
David L. L. Thomas committed
212
    content Markdown
Mitchell Rosen's avatar
Mitchell Rosen committed
213
    archived Bool -- Put into the "trash bin".
David L. L. Thomas's avatar
David L. L. Thomas committed
214

215 216 217 218 219 220 221 222
-- A many-to-one relationship linking messages sent to moderators about an
-- unapproved comment. When the comment is approved, all such messages are
-- deleted automatically (as they are no longer relevant) - this table
-- allows us to keep track of which messages to delete.
UnapprovedMessageComment
    message MessageId
    comment CommentId

David L. L. Thomas's avatar
David L. L. Thomas committed
223
WikiPage
224
    createdTs UTCTime default=now()
David L. L. Thomas's avatar
David L. L. Thomas committed
225
    target Text
226
    project ProjectId
David L. L. Thomas's avatar
David L. L. Thomas committed
227
    content Markdown
228
    discussion DiscussionId
229
    permissionLevel PermissionLevel
230
    UniqueWikiTarget project target
Mitchell Rosen's avatar
Mitchell Rosen committed
231
    deriving Eq
David L. L. Thomas's avatar
David L. L. Thomas committed
232 233 234 235 236

WikiEdit
    ts UTCTime
    user UserId
    page WikiPageId
237
    content Markdown
David L. L. Thomas's avatar
David L. L. Thomas committed
238
    comment Text Maybe
Mitchell Rosen's avatar
Mitchell Rosen committed
239
    deriving Eq
David L. L. Thomas's avatar
David L. L. Thomas committed
240 241 242 243 244 245

WikiLastEdit
    page WikiPageId
    edit WikiEditId
    UniqueWikiLastEdit page

246
Discussion
247
    nothing Int64
248

249
Comment
David L. L. Thomas's avatar
David L. L. Thomas committed
250
    createdTs UTCTime
251 252 253 254

    -- "Unestablished" users may still make comments, but they must be approved
    -- by a moderator. "Established" users' comments are marked as moderated by
    -- themselves (though this does not mean they are a moderator).
255
    moderatedTs UTCTime Maybe
256
    moderatedBy UserId Maybe
257

258
    discussion DiscussionId
259
    parent CommentId Maybe
David L. L. Thomas's avatar
David L. L. Thomas committed
260 261
    user UserId
    text Markdown
David L. L. Thomas's avatar
David L. L. Thomas committed
262
    depth Int
Mitchell Rosen's avatar
Mitchell Rosen committed
263
    deriving Eq Show
David L. L. Thomas's avatar
David L. L. Thomas committed
264

265 266
-- A comment has zero or more ancestors: its parent, grandparent, great
-- grandparent, etc.
267 268 269 270
CommentAncestor
    comment CommentId
    ancestor CommentId
    UniqueCommentAncestor comment ancestor
271
    deriving Show
272

273
-- A comment-being-closed event.
David L. L. Thomas's avatar
David L. L. Thomas committed
274
CommentClosure
275
    ts UTCTime
276
    closedBy UserId
David L. L. Thomas's avatar
David L. L. Thomas committed
277
    type ClosureType
278 279
    reason Markdown
    comment CommentId
280

281
-- A rethread event. Moderators may move comment threads around as they wish.
282
Rethread
283 284 285 286
    ts UTCTime            -- Timestamp.
    moderator UserId      -- The moderator that rethreaded.
    oldComment CommentId  -- The old comment that was rethreaded.
    reason Text           -- The reason for rethreading.
287

288
-- A flagging event, with one or more reason stored in CommentFlaggingReason.
289 290 291 292
CommentFlagging
    ts UTCTime
    flagger UserId
    comment CommentId
Mitchell Rosen's avatar
Mitchell Rosen committed
293 294 295 296 297 298

    -- These two fields are required to reconstruct the permalink to the comment,
    -- for inclusion in messages to the flagger/flaggee.
    projectHandle Text
    target Text

299
    message Markdown Maybe -- Optional message provided by the flagger.
Mitchell Rosen's avatar
Mitchell Rosen committed
300 301
    -- Only one flagging can exist for a comment at any given time.
    UniqueCommentFlagging comment
302 303 304 305

-- A reason associated with a comment flagging. One-to-many relation.
CommentFlaggingReason
    flagging CommentFlaggingId
306
    reason FlagReason
307
    UniqueCommentFlaggingReason flagging reason
308

309
-- An individual comment-rethread relation.
310 311 312 313 314
CommentRethread
    rethread RethreadId
    oldComment CommentId
    newComment CommentId

David L. L. Thomas's avatar
David L. L. Thomas committed
315 316 317 318 319 320 321 322 323
Tag
    name Text
    UniqueTag name

ProjectTag
    project ProjectId
    tag TagId
    UniqueProjectTag project tag

David L. L. Thomas's avatar
David L. L. Thomas committed
324 325 326 327
CommentTag
    comment CommentId
    tag TagId
    user UserId
David L. L. Thomas's avatar
David L. L. Thomas committed
328
    count Int default=1
David L. L. Thomas's avatar
David L. L. Thomas committed
329 330
    UniqueCommentTag comment tag user

331
-- A Comment can have at most one Ticket (i.e. the comment can be marked as a ticket)
David L. L. Thomas's avatar
David L. L. Thomas committed
332 333
Ticket
    createdTs UTCTime
334
    updatedTs UTCTime
David L. L. Thomas's avatar
David L. L. Thomas committed
335 336
    name Text
    comment CommentId
337
    UniqueTicket comment
David L. L. Thomas's avatar
David L. L. Thomas committed
338

339 340 341 342 343
Build
    bootTime UTCTime
    base Text
    diff Text

344 345
-- A User may be established by a number of different ways. Manual establishment
-- by a moderator is one of them.
346
ManualEstablishment
347 348
    establishedUser UserId
    establishingUser UserId
349 350
    UniqueManualEstablishment establishedUser

David L. L. Thomas's avatar
David L. L. Thomas committed
351 352 353 354 355 356 357 358 359 360 361 362
TagColor
    tag TagId
    user UserId
    color Int
    UniqueTagColor tag user
    deriving Typeable

DefaultTagColor
    tag TagId
    color Int
    UniqueDefaultTag tag

David L. L. Thomas's avatar
David L. L. Thomas committed
363 364 365 366 367 368 369
RoleEvent
    time UTCTime
    user UserId
    role Role
    project ProjectId
    added Bool

David L. L. Thomas's avatar
David L. L. Thomas committed
370 371 372 373 374 375 376 377 378
Doc
    name Text
    currentVersion WikiEditId
    UniqueDocName name

DocEvent
    time UTCTime
    doc DocId
    blessedVersion WikiEditId
David L. L. Thomas's avatar
David L. L. Thomas committed
379

David L. L. Thomas's avatar
David L. L. Thomas committed
380 381 382
DatabaseVersion
    lastMigration Int

383 384 385
PledgeFormRendered
    ts UTCTime
    order Text
386
    project ProjectId
387 388 389 390
    user UserId Maybe

SharesPledged
    ts UTCTime
391
    user UserId
392
    project ProjectId
393
    shares Int64
394 395
    render PledgeFormRenderedId

Mitchell Rosen's avatar
Mitchell Rosen committed
396 397 398 399 400 401 402
--------------------------------------------------------------------------------
-- Snowdrift events. These are all combined into a single sum time in 
-- Model.SnowdriftEvent.

-- An approved comment.
EventCommentPosted
    ts UTCTime
403
    comment CommentId
Mitchell Rosen's avatar
Mitchell Rosen committed
404 405 406 407

-- An unapproved comment.
EventCommentPending
    ts UTCTime
408
    comment CommentId
Mitchell Rosen's avatar
Mitchell Rosen committed
409

410
-- Message sent event.
Mitchell Rosen's avatar
Mitchell Rosen committed
411 412
EventMessageSent
    ts UTCTime
413
    message MessageId
Mitchell Rosen's avatar
Mitchell Rosen committed
414

415 416 417
-- Wiki page created event.
EventWikiPage
    ts UTCTime
418
    wikiPage WikiPageId
419 420

-- Wiki edit made event.
Mitchell Rosen's avatar
Mitchell Rosen committed
421
EventWikiEdit
422
    ts UTCTime
Mitchell Rosen's avatar
Mitchell Rosen committed
423
    wikiEdit WikiEditId
424 425

EventNewPledge
Mitchell Rosen's avatar
Mitchell Rosen committed
426
    ts UTCTime
427
    sharesPledged SharesPledgedId
428 429 430 431

EventUpdatedPledge
    ts UTCTime
    oldShares Int64
432
    sharesPledged SharesPledgedId
433 434 435 436 437 438

EventDeletedPledge
    ts UTCTime
    user UserId
    project ProjectId
    shares Int64