Skip to content

Database Schema

Auto-generated from services/api/server/db/schema.ts. Do not edit manually. Run pnpm run docs:generate:db to regenerate.

PostgreSQL with Drizzle ORM. Migrations auto-apply on startup via the 0.migrate.ts plugin.

Enums

book_status

Values: inbox, review, organized

Tables

TableDescription
booksMain book records with status, metadata, and search vectors
book_filesPhysical file storage (format, checksums, paths)
book_metadata_candidatesMetadata fetched from external sources (Google Books, Hardcover)
reading_progressCurrent KoSync reading position per document/device
reading_progress_historyHistorical reading progress snapshots
service_credentialsStored credentials for OPDS, KoSync, Hardcover, Google Books
api_keysAPI key records (hashed, with labels)
hardcover_sync_logHardcover book sync tracking per library book

books

ColumnTypeNullableDefaultNotes
iduuidYesrandom()PK
statusenum(book_status)Noinbox
titletextYes
authortextYes
isbn_10textYes
isbn_13textYes
publishertextYes
published_yearintegerYes
languagetextYes
descriptiontextYes
cover_urltextYes
cover_pathtextYes
page_countintegerYes
genrestext[]No[]
tagstext[]No[]
hardcover_book_idintegerYes
hardcover_edition_idintegerYes
possible_duplicate_ofuuidYes
approved_attimestamptzYes
created_attimestamptzNonow()
updated_attimestamptzNonow()
search_vectortsvectorYes

book_files

ColumnTypeNullableDefaultNotes
iduuidYesrandom()PK
book_iduuidNoFK → books.id
formattextNo
original_nametextNo
storage_pathtextYes
inbox_pathtextYes
file_sizebigintNo0
checksumtextYes
content_hashtextYes
created_attimestamptzNonow()
updated_attimestamptzNonow()

book_metadata_candidates

ColumnTypeNullableDefaultNotes
iduuidYesrandom()PK
book_iduuidNoFK → books.id
sourcetextNo
raw_responsejsonbYes
normalizedjsonbNo{}
confidencenumeric(5,4)No0
selected_fieldstext[]No[]

reading_progress

ColumnTypeNullableDefaultNotes
iduuidYesrandom()PK
documenttextNo
devicetextNo
device_idtextYes
progresstextNo
percentagenumeric(5,4)No0
timestampbigintNo0
raw_payloadjsonbYes
updated_attimestamptzNonow()

reading_progress_history

ColumnTypeNullableDefaultNotes
iduuidYesrandom()PK
documenttextNo
devicetextNo
progresstextNo
percentagenumeric(5,4)No0
timestampbigintNo0
created_attimestamptzNonow()

service_credentials

ColumnTypeNullableDefaultNotes
iduuidYesrandom()PK
servicetextNo
usernametextNo
password_hashtextNo
created_attimestamptzNonow()
updated_attimestamptzYes

api_keys

ColumnTypeNullableDefaultNotes
iduuidYesrandom()PK
key_prefixtextNo
key_hashtextNo
labeltextNo
created_attimestamptzNonow()
last_used_attimestamptzYes

hardcover_sync_log

ColumnTypeNullableDefaultNotes
iduuidYesrandom()PK
book_iduuidNoFK → books.id
hardcover_user_book_idintegerYes
hardcover_read_idintegerYes
last_statustextYes
last_progressnumeric(5,4)Yes
last_ratingnumeric(3,1)Yes
last_synced_attimestamptzNo
created_attimestamptzNonow()
updated_attimestamptzNonow()

Relationships

mermaid
erDiagram
    books ||--o{ book_files : "has many"
    books ||--o{ book_metadata_candidates : "has many"
    books ||--o{ hardcover_sync_log : "has many"