Database structure
FKMTime uses PostgreSQL database to store all the data. The source of truth is
backend/prisma/schema.prisma
in the FKMTime repository; this page describes the tables in it.
We use Prisma ORM to interact with the database. You can read more about Prisma here.
We are using camelCase in our code, although the database is using snake_case. Prisma is taking care of the conversion using @map.
We are using UUIDs as primary keys for all tables.
Tables
Competition
There is one record in this table. It stores the competition settings, WCIF and other general data. Most of the data in this table is inserted during the import from the WCA website.
id- unique identifiername- competition namewcaId- WCA competition IDcountryIso2- country ISO2 codewcif- JSON, stores public WCIF of the competitionsendingResultsFrequency- SendingResultsFrequency, how often results are sentscoretakingToken- token taken from WCA Live for entering resultsscoretakingTokenUpdatedAt- date the scoretaking token was last savedwcaScoretakingSoftware- the competition's scoretaking software as set on the WCA website, null until first readwcaScoretakingCheckedAt- date FKMTime last read itwcaLiveConnectedById,wcaLiveConnectedWcaUserId,wcaLiveConnectedName- the account results are entered as in WCA integrated live resultswcaLiveCanEnterScores- boolean, if that account can enter scoreswcaLiveAccessToken,wcaLiveRefreshToken- encrypted tokens of that accountwcaLiveTokenExpiresAt- date the access token expireswcaLiveConnectionBrokenAt- date the connection stopped working, if it didopenRoundsAutomatically- boolean, if FKMTime opens later rounds in WCA integrated live results itself (off: a person does it)cubingContestsToken- token taken from Cubing Contests for entering resultsdefaultLocale- default language of the panelshouldUpdateDevices- boolean, if the devices should be updated with new releasesshouldChangeGroupsAutomatically- boolean, if the groups should be changed automaticallywifiSsid- Wi-Fi SSID that FKMTime devices will be using to connect to micro-connectorwifiPassword- Wi-Fi passwordmdns- boolean, whether mDNS should be used to discover the serverwsUrl- websocket URL if mDNS is not usedfkmToken- token that FKMTime devices usesecureRfid- boolean, if secure RFID is useduseFkmTimeDevices- boolean, if the competition uses FKMTime devicessoundEnabled- boolean, if devices play soundsbuzzerVolume- buzzer volume for v4 stations, null leaves each station on its own setting
UnofficialEvent
This table stores unofficial events that are held during the competition.
id- unique identifiereventId- id taken frombackend/src/events.tswcif- event data in WCIF format (stored as JSON)createdAt- date of creationupdatedAt- date of last update
Room
This table stores rooms taken from WCIF during import.
id- unique identifiername- room namecolor- room colorcurrentGroupIds- array of WCIF group IDs that are currently taking place in the room, may be emptystartedGroupIds- array of every WCIF group ID the room has started, so a round counts as over only once all of its groups have runcreatedAt- date of creationupdatedAt- date of last update
Device
This table stores data about all FKMTime devices that are connected to the system.
id- unique identifiername- device name, can be changedespId- ESP32 device IDsignKey- key the device signs its messages withtype- DeviceTypebatteryPercentage- battery percentage, updated automaticallyhwVersion- HardwareVersionfirmwareVersion- firmware version the device runsretiredAt- set instead of deleting a device that has history, so its attempts keep their stationcustomGroupId- group the station runs instead of its room's groups, null while it follows its roomcustomRoundId- no longer used; a station still pointed at a round moves to that round's last group when FKMTime startscustomRoundSetAt,customRoundSetById- when and by which User the custom group was settutorialEndsAt- while in the future, the station takes tutorial solves, which are never savedtutorialStartedById- User that started the tutorialroomId- RoomcreatedAt- date of creationupdatedAt- date of last update
User
All user accounts are stored in this table, both FKMTime and WCA accounts added to the system.
id- unique identifierpassword- hashed password, only available for FKMTime accountsusername- username, only available for FKMTime accountsroles- array of RolefullName- full name of the userwcaUserId- WCA user ID, only available for WCA accountswcaAccessToken- WCA access token, only available for WCA accountstokenVersion- bumped when the password changes, so sessions signed in before stop workingavatarUrl- WCA avatar URLcreatedAt- date of creationupdatedAt- date of last update
StageLeadRoom
The rooms a stage leader takes attendance in. A stage leader with no rows covers all rooms.
QuickAction
This table stores quick actions that can be used to simplify resolving incidents process by delegates.
id- unique identifiername- action namecomment- comment that will be added to the attemptgiveExtra- boolean, if the action should give extra attemptisShared- boolean, if the action is shared between all usersuserId- User that created the actioncreatedAt- date of creationupdatedAt- date of last update
Person
This table stores data about competitors and staff members. Most data are inserted during import and sync.
id- unique identifierregistrantId- WCA registrant IDwcaRegistrationId- the WCA registration's database id, null for people created on sitename- full namewcaId- WCA IDcountryIso2- country ISO2 codegender- gendercanCompete- boolean, if the person can competebirthdate- date of birth, null for all persons except newcomerscheckedInAt- date of check-incardId- assigned card ID
StaffActivity
This table stores data about all staff/competing activities, pre-assigned and performed during the competition.
id- unique identifierpersonId- PersondeviceId- Device (can be null)isAssigned- boolean, if the activity is pre-assignedstatus- StaffActivityStatusgroupId- WCIF group IDrole- StaffRole, role of the person in the groupcomment- commentleftEarly- boolean, left before the group ended (only withPRESENTorLATE)noShow- boolean, not coming for the rest of the day (only withABSENT)replacedById- Person who did the job instead (only withREPLACEDorABSENT)createdAt- date of creationupdatedAt- date of last update
Result
This table stores all results that are entered during the competition.
id- unique identifierpersonId- PersoneventId- event ID, taken frombackend/src/events.tsroundId- round ID in WCIF formatisDoubleChecked- boolean, if the result was already double-checkeddoubleCheckedById- User that double-checked the resultdoubleCheckedAt- date of double-checkingremovedAt- set when the result was removed under Regulation 9t; it is kept, but left out of every listremovedById- User that removed itremovedReason- why it was removedremovedByRulingOfId- the Result whose DNF ruling removed this one; restoring that result brings this one backcreatedAt- date of creationupdatedAt- date of last update
Attempt
This table is the biggest table, it stores all attempts that are entered during the competition.
id- unique identifiersessionId- unique identifier generated by FKMTime device that prevents from entering the same attempt twiceresultId- ResultattemptNumber- number of the attemptreplacedBy- number of the attempt that replaced this one (if extra attempt was granted)comment- comment for the attempt, added by the delegatetype- AttemptTypestatus- AttemptStatuspenalty- penalty in seconds added to the timevalue- time in centisecondsoriginalTime- exact time taken from stackmat, in millisecondsinspectionTime- inspection time measured by the devicejudgeId- Person that judged the attemptscramblerId- Person that scrambled the attemptscrambledAt- date of scramblingdeviceId- Device that was used to enter the attempt (can be null if attempt was entered manually)solvedAt- date of finishing the solveupdatedById- User that last edited the attemptextraGrantId- ExtraGrant this attempt belongs tostatusBeforeGrant,statusInGrant,replacedByInGrant- the attempt's state before and within an extra grant, so the grant can be undonecreatedAt- date of creationupdatedAt- date of last update
ExtraGrant
An extra granted for all attempts of a result so far.
id- unique identifierresultId- ResultuseFreshSet- boolean, if the extras use a fresh scramble setcreatedById- User that granted itcreatedAt- date of creationrestoredAt- date the grant was undone
AttemptEditLog
Every change to an attempt, with the attempt's values before the change.
id- unique identifierattemptId- AttempteditedAt- date of the changeeditedById- User that made the changecomment- why the attempt was changedvalue,penalty,status,type,attemptNumber,replacedBy,judgeId,scramblerId,deviceId,attemptComment- the attempt's values
NoteworthyIncident
Incidents marked as noteworthy, for example to report to the WCA.
id- unique identifiertitle- titledescription- descriptionattemptId- AttemptcreatedById- User that created itcreatedAt- date of creationupdatedAt- date of last update
ManualIncident
Incidents entered by hand, not tied to an attempt in the system.
id- unique identifierpersonId- PersonroundId- round ID in WCIF formatdescription- descriptionattempt- attempt it is aboutisNoteworthy- boolean, if the incident is noteworthycreatedById- User that created itcreatedAt- date of creationupdatedAt- date of last update
Warning
Warnings given to competitors.
id- unique identifierdescription- descriptionpersonId- Person that received the warningcreatedById- User that gave itcreatedAt- date of creationupdatedAt- date of last update
DelegateGrant
Delegate access for one group: a delegate lets a user resolve the group's incidents while it runs. See Delegate access for one group.
id- unique identifieruserId- User who got the accessgroupId- WCIF group activity code, e.g.333-r1-g2permissions- array of DelegateGrantPermission, what they can do besides resolving incidentscreatedById- User that gave itcreatedAt- date of creationactivatedAt- when the group started in its room, null while the access waits for the groupendedAt- date the access ended, by itself or ended by a delegateendedById- User that ended it early
DelegateGrantAction
What a user did under delegate access, for delegates to look over.
id- unique identifiergrantId- DelegateGrantkind- what kind of action it was, e.g. resolving an incident or giving an extraresultId,attemptId- the result and attempt it changed. Plain IDs, not relations, so the action stays after the attempt is deletedpersonName- the competitor's namesummary- what changed, in wordscreatedAt- date of creation
LiveSync
Where each result stands in WCA integrated live results.
resultId- Resultstatus- LiveSyncStatussentHash- hash of the attempts last sent, compared with what the WCA holdssentAt- date of sendingchecks- number of read-backs that didn't match yetremovedFromRound- boolean, FKMTime removed the competitor from the round, so restoring the result has to add them back firsterror- last errorupdatedAt- date of last update
LiveClear
A result deleted in FKMTime whose copy in WCA integrated live results still has to be cleared.
id- unique identifierroundId- round ID in WCIF formatwcaRegistrationId- WCA registration ID of the competitorcreatedAt- date of creation
ScramblingDevice
This table stores data about scrambling devices (e. g. laptops) that are used during the competition.
id- unique identifiername- device nameencryptedToken- token used to authenticate the deviceencryptedOneTimeCode- one-time code used to pair the deviceoneTimeCodeExpiresAt- date the one-time code stops workingroomId- RoomcreatedAt- date of creationupdatedAt- date of last update
ScrambleSet
id- unique identifierroundId- round ID in WCIF formatset- letter, e. g. "A"createdAt- date of creationupdatedAt- date of last update
Scramble
id- unique identifierscrambleSetId- ScrambleSetnum- number of the scramble in the setisExtra- boolean, if the scramble is extraencryptedScramble- encrypted scramblecreatedAt- date of creationupdatedAt- date of last update
Enums
AttemptType
STANDARD_ATTEMPT- applied for all normal attemptsEXTRA_ATTEMPT- applied for extra attempts
AttemptStatus
SCRAMBLED- the attempt was scrambled, but not solved yetSTANDARD- applied for all normal attemptsUNRESOLVED- applied for incidents that need to be resolvedRESOLVED- applied for resolved incidents, without extraEXTRA_GIVEN- applied for resolved incidents, with extraVOIDED- an attempt waiting for an extra that can never come, because the competitor missed the cutoff
Role
See Accounts for what each role can do.
ADMINORGANIZERDELEGATESTAGE_LEADERSTAFF
DeviceType
STATION- device that is used to enter resultsATTENDANCE_SCRAMBLER- staff attendance device for scramblersATTENDANCE_RUNNER- staff attendance device for runners
HardwareVersion
V3V4
DelegateGrantPermission
What delegate access allows besides resolving incidents.
GIVE_EXTRA- give an extraADD_ATTEMPT- add an attemptREORDER_ATTEMPTS- reorder attemptsEDIT_ATTEMPT- edit an attempt that isn't an incidentDELETE_ATTEMPT- delete an attemptEXTRAS_FOR_SEVERAL- give extras for several attemptsDNF_ALL- DNF all attempts
StaffRole
COMPETITOR- competitorJUDGE- judgeRUNNER- runnerSCRAMBLER- scramblerDELEGATE- delegateSTAFF_OTHER- other staff
StaffActivityStatus
PRESENT- was thereABSENT- wasn't thereLATE- came lateREPLACED- someone else did the job
SendingResultsFrequency
AFTER_SOLVE- selected by default, results are sent after each solveEVERY_5_MINUTES- results are sent every 5 minutesNEVER- results are not sent
LiveSyncStatus
DIRTY- changed since it was last sentSENT- the WCA accepted it, not read back yetCONFIRMED- read back from the WCA and matchesNOT_IN_ROUND- the WCA doesn't list the person in the roundNOT_SENDABLE- can't be sent, e.g. the person has no WCA registrationREJECTED- the WCA refused it, or it breaks the round's rules