Skip to content

Database Schema

Auto-generated from services/api-hono/src/db/schema.ts. Do not edit manually. Run vp run -F @libris/docs generate:db -- --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

reading_status

Values: unread, reading, finished, paused

Tables

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

api_keys

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

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
seriestextYes
series_indexrealYes
genrestext[]No[]
tagstext[]No[]
hardcover_book_idintegerYes
hardcover_edition_idintegerYes
created_byuuidYesFK → apiKeys.id
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
original_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
book_iduuidYesFK → books.id
api_key_iduuidNoFK → apiKeys.id
documenttextNo
devicetextNo
device_idtextYes
progresstextNo
percentagenumeric(5,4)No0
timestampbigintNo0
raw_payloadjsonbYes
updated_attimestamptzNonow()

reading_progress_history

ColumnTypeNullableDefaultNotes
iduuidYesrandom()PK
book_iduuidYesFK → books.id
api_key_iduuidYesFK → apiKeys.id
documenttextNo
devicetextNo
progresstextNo
percentagenumeric(5,4)No0
timestampbigintNo0
created_attimestamptzNonow()

reading_aggregate

ColumnTypeNullableDefaultNotes
iduuidYesrandom()PK
api_key_iduuidNoFK → apiKeys.id
book_iduuidYesFK → books.id
started_attimestamptzYes
finished_attimestamptzYes
manual_statusenum(reading_status)Yes
manual_started_attimestamptzYes
manual_finished_attimestamptzYes
manual_paused_attimestamptzYes
manual_set_attimestamptzYes
external_statusenum(reading_status)Yes
external_status_synced_attimestamptzYes
updated_attimestamptzNonow()

service_credentials

ColumnTypeNullableDefaultNotes
iduuidYesrandom()PK
servicetextNo
api_key_iduuidNoFK → apiKeys.id
usernametextNo
password_hashtextNo
created_attimestamptzNonow()
updated_attimestamptzNonow()

app_settings

ColumnTypeNullableDefaultNotes
keytextYesPK
valuejsonbNo
updated_attimestamptzNonow()

upload_registry

ColumnTypeNullableDefaultNotes
iduuidYesrandom()PK
checksumtextNo
api_key_iduuidNoFK → apiKeys.id
filenametextNo
created_attimestamptzNonow()

hardcover_sync_log

ColumnTypeNullableDefaultNotes
iduuidYesrandom()PK
book_iduuidNoFK → books.id
api_key_iduuidNoFK → apiKeys.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
    apiKeys ||--o{ books : "has many"
    books ||--o{ book_files : "has many"
    books ||--o{ book_metadata_candidates : "has many"
    books ||--o{ reading_progress : "has many"
    apiKeys ||--o{ reading_progress : "has many"
    books ||--o{ reading_progress_history : "has many"
    apiKeys ||--o{ reading_progress_history : "has many"
    apiKeys ||--o{ reading_aggregate : "has many"
    books ||--o{ reading_aggregate : "has many"
    apiKeys ||--o{ service_credentials : "has many"
    apiKeys ||--o{ upload_registry : "has many"
    books ||--o{ hardcover_sync_log : "has many"
    apiKeys ||--o{ hardcover_sync_log : "has many"