fix(schema): widen media_items.genre to TEXT
The genre column was VARCHAR(100), and the audio tag fallback stores the
file's raw genre atom verbatim. Libation writes Audible's category ladder
as one comma-joined string ("Politicians, Presidents & Heads of State,
United States, Russia, Communism & Socialism, International Relations" —
111 chars), so any such book failed its import or metadata update with
SQLSTATE 22001 (value too long), taking the whole row down with it.
VARCHAR -> TEXT is a metadata-only change in Postgres and safe to re-run;
the in-place ALTER follows the media_highlights position-widening
precedent so existing databases converge on restart (schema.sql runs on
every boot).
This commit is contained in:
1 parent
8c97f59453
commit
d42c78f58c
1 file changed
+9
-1
@@ -174,7 +174,7 @@ CREATE TABLE IF NOT EXISTS media_items (
|
||||
language VARCHAR(10) DEFAULT 'en', -- Language code (ISO 639-1)
|
||||
edition VARCHAR(100), -- Edition information
|
||||
page_count INTEGER, -- Total page count
|
||||
genre VARCHAR(100), -- Genre classification
|
||||
genre TEXT, -- Genre classification (smart-genre shelf OR raw tag free text — Audible category strings exceed 100 chars)
|
||||
copyright_year INTEGER, -- Copyright/publication year
|
||||
goodreads_id VARCHAR(50), -- Goodreads identifier
|
||||
openlibrary_id VARCHAR(50), -- Open Library identifier
|
||||
@@ -279,6 +279,14 @@ CREATE INDEX IF NOT EXISTS idx_media_items_contributors_gin ON media_items USING
|
||||
ALTER TABLE media_items ADD COLUMN IF NOT EXISTS tags_search TEXT[];
|
||||
ALTER TABLE media_items ADD COLUMN IF NOT EXISTS contributors_search TEXT[];
|
||||
|
||||
-- Widen genre for existing databases: the audio tag fallback stores the
|
||||
-- raw file genre atom (Audible category strings exceed 100 chars —
|
||||
-- e.g. "Politicians, Presidents & Heads of State, United States, ..."),
|
||||
-- and VARCHAR(100) rejected the whole import/update at the database
|
||||
-- layer (SQLSTATE 22001). VARCHAR -> TEXT is a metadata-only change,
|
||||
-- safe to re-run (media_highlights position widening precedent).
|
||||
ALTER TABLE media_items ALTER COLUMN genre TYPE TEXT;
|
||||
|
||||
-- Audiobook editorial facts (A2a): narrators are user-editable first-class
|
||||
-- (search/filter/badge surface); abridged rides along; audio_metadata keeps
|
||||
-- the scan-derived tech record (duration/codec/chapters).
|
||||
|
||||
Reference in new issue
Block a user