mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-02 22:46:55 -05:00
[Enhancement]: Postgres support #3211
Labels
No labels
authentication
awaiting release
backlog
bug
chapter editor
config-issue
ebooks
encoding/embedding
enhancement
help wanted
listening sessions & progress
planned
possible plugin
progress sync
sorting/filtering/searching
unable to reproduce
upload
users & permissions
waiting
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/audiobookshelf-advplyr#3211
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @twsouthwick on GitHub (Jan 31, 2026).
Type of Enhancement
Server Backend
Describe the Feature/Enhancement
Add PostgreSQL as an alternative database backend while keeping SQLite as the default.
#2046 already exists, but this a proposal that I wanted to discuss how to actually accomplish this.
Why would this be helpful?
In some hosting setups (such as kubernetes) it's easier to separate out the data concerns from the app so there's more control over the storage setup.
Future Implementation (Screenshot)
Approach
This breaks the addition of PostgreSQL support to two steps: prepatory work and enablign postgres.
The existing codebase has some existing sqlite-specific code. To prepare for postgres, there are two approaches that could be taken to address this:
Phase 1A: Dialect Abstraction (no behavior change)
Example dialect specific changes:
json_each(column)jsonb_array_elements_text(column)GROUP_CONCAT(col, ', ')STRING_AGG(col, ', ')COLLATE NOCASELOWER(column)IFNULL(a, b)COALESCE(a, b)Phase 1B: Schema Normalization (alternate approach)
Convert JSON blob columns to proper relational tables, eliminating dialect-specific JSON functions entirely.
JSON columns actively queried (require normalization):
booksnarratorsnarrators+book_narratorsbookstagstags+book_tagsbooksgenresgenres+book_genrespodcaststagstags+podcast_tagspodcastsgenresgenres+podcast_genresJSON columns NOT queried (keep as-is):
These columns store metadata blobs read/written as a whole and don't need SQL-level filtering:
booksaudioFiles,ebookFile,chapterspodcastEpisodesaudioFile,chapters,extraDatalibraryItemslibraryFiles,extraDatauserspermissions,bookmarks,extraDatalibrariessettings,extraDataplaybackSessionsmediaMetadata,extraDatasettingsvaluemediaProgressextraDatadevices,apiKeys,mediaItemShares,customMetadataProvidersextraData/permissionsPhase 2: Enable PostgreSQL
pgandpg-hstoredependenciesConfiguration:
Out of Scope
Audiobookshelf Server Version
2.32.1
Current Implementation (Screenshot)
No response
@nichwall commented on GitHub (Jan 31, 2026):
This probably makes more sense as a discussion since there is already a Postgres issue like you mentioned.