Skip to content

Database Schema

The PREQSTATION database stores tasks, project metadata, work logs, and audit history. The current schema is defined in projects-manager/lib/db/schema.ts.

Core Tables

users

Single-owner account table.

ColumnTypePurpose
idUUIDPrimary key
emailTextLogin email
nameTextOptional display name
isOwnerBooleanSingle-owner flag
createdAtTimestampCreation time
updatedAtTimestampLast update

projects

Tracked repositories and deployment targets.

ColumnTypePurpose
idUUIDPrimary key
ownerIdUUIDOwner foreign key
projectKeyTextStable project key such as PROJ
nameTextProject display name
descriptionTextOptional description
repoUrlTextRepository URL
vercelUrlTextOptional deployment URL
statusTextProject status
priorityIntegerOrdering priority
bgImageTextBackground image or preset
bgImageCreditJSONBAttribution metadata
deletedAtTimestampSoft delete timestamp
createdAtTimestampCreation time
updatedAtTimestampLast update

project_settings

Per-project configuration is stored as key/value rows, not as wide columns.

ColumnTypePurpose
idUUIDPrimary key
projectIdUUIDProject foreign key
keyTextSetting name
valueTextSetting value
createdAtTimestampCreation time
updatedAtTimestampLast update

Common keys:

  • deploy_strategy
  • deploy_default_branch
  • deploy_auto_pr
  • deploy_commit_on_review
  • deploy_squash_merge
  • agent_instructions

tasks

Task cards with workflow status plus execution overlay fields.

ColumnTypePurpose
idUUIDPrimary key
ownerIdUUIDOwner foreign key
projectIdUUIDRelated project
labelIdUUIDLegacy primary label pointer
taskKeyTextHuman-readable key such as PROJ-123
taskPrefixTextProject key portion
taskNumberIntegerSequence number within the project
titleTextTask title
noteTextDescription plus acceptance criteria markdown
statusTextinbox, todo, hold, ready, done, archived
taskPriorityTexthighest, high, medium, none, low, lowest
branchTextBranch name used for work
engineTextclaude-code, codex, or gemini-cli
runStateTextInternal execution state: queued, running, or null
runStateUpdatedAtTimestampLast run-state update
dueAtTimestampOptional due date
focusedAtTimestampToday-focus pin timestamp
sortOrderVarcharFractional ordering key for Kanban
archivedAtTimestampArchive time
createdAtTimestampCreation time
updatedAtTimestampLast update

External task APIs serialize runState="running" as run_state="working" so API clients do not need to know the internal label.

task_labels

Owner-scoped label taxonomy.

ColumnTypePurpose
idUUIDPrimary key
ownerIdUUIDOwner foreign key
nameTextUnique label name per owner
colorTextStored color value
createdAtTimestampCreation time
updatedAtTimestampLast update

task_label_assignments

Join table between tasks and labels.

ColumnTypePurpose
idUUIDPrimary key
taskIdUUIDTask foreign key
labelIdUUIDLabel foreign key
positionIntegerDisplay order within the task
createdAtTimestampCreation time

API and Audit Tables

api_tokens

Bearer tokens for agent authentication.

ColumnTypePurpose
idUUIDPrimary key
ownerIdUUIDOwner foreign key
nameTextToken display name
tokenPrefixTextPublic prefix (preq_...)
tokenHashTextSHA-256 hash
lastUsedAtTimestampLast successful use
expiresAtTimestampOptional expiration
revokedAtTimestampRevocation time
createdAtTimestampCreation time
updatedAtTimestampLast update

work_logs

Durable timeline entries for manual work logs and agent results.

ColumnTypePurpose
idUUIDPrimary key
ownerIdUUIDOwner foreign key
projectIdUUIDOptional project foreign key
taskIdUUIDOptional task foreign key
titleTextWork log title
detailTextWork log body
engineTextEngine that produced the entry
workedAtTimestampWhen the work happened
createdAtTimestampCreation time

events_outbox

Append-only event stream for downstream processing.

ColumnTypePurpose
idBigSerialMonotonic event cursor
ownerIdUUIDOwner foreign key
projectIdUUIDRelated project when available
eventTypeTextEvent name such as TASK_STATUS_CHANGED
entityTypeTexttask, project, or worklog
entityIdTextTask key, UUID, or work log id
payloadJSONBEvent-specific metadata
createdAtTimestampCreation time

audit_logs

Immutable record of application mutations.

ColumnTypePurpose
idUUIDPrimary key
ownerIdUUIDOwner foreign key
actionTextAction name
targetTypeTextResource type
targetIdTextResource identifier
metaJSONBStructured metadata
createdAtTimestampCreation time

security_events

Authentication and authorization history.

ColumnTypePurpose
idUUIDPrimary key
ownerIdUUIDOwner foreign key (nullable)
actorEmailTextEmail tied to the event
eventTypeTextEvent name
outcomeTextsuccess or failure
ipAddressTextSource IP
userAgentTextUser agent
pathTextRoute involved
detailJSONBExtra context
createdAtTimestampCreation time

user_settings

Owner-scoped key/value settings.

ColumnTypePurpose
idUUIDPrimary key
ownerIdUUIDOwner foreign key
keyTextSetting name
valueTextSetting value
createdAtTimestampCreation time
updatedAtTimestampLast update

Common keys:

  • telegram_bot_token
  • telegram_chat_id
  • telegram_enabled

Notes

  • Projects are soft-deleted through deletedAt.
  • Tasks keep workflow status and execution state separate.
  • Labels are many-to-many through task_label_assignments.
  • Event ids are monotonic cursors, which is why /api/events returns nextCursor.