fix: sync database queries with enhanced media-items schema
- Add missing enhanced fields to CreateMediaItem INSERT statement - Add missing enhanced fields to UpdateMediaItem UPDATE statement - Include language, edition, page_count, genre, copyright_year - Include integration fields: goodreads_id, openlibrary_id, google_books_id - Add corresponding indexes for enhanced fields - Add column comments for better documentation - Resolves schema-query mismatch causing field removal cycles
This commit is contained in:
@@ -92,6 +92,15 @@ CREATE TABLE media_items (
|
||||
date_published DATE,
|
||||
publisher VARCHAR(255),
|
||||
contributors TEXT,
|
||||
-- Enhanced fields for better metadata and functionality
|
||||
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
|
||||
copyright_year INTEGER, -- Copyright/publication year
|
||||
goodreads_id VARCHAR(50), -- Goodreads identifier
|
||||
openlibrary_id VARCHAR(50), -- Open Library identifier
|
||||
google_books_id VARCHAR(100), -- Google Books identifier
|
||||
added_by_admin_id UUID REFERENCES users(id) ON DELETE SET NULL,
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
||||
@@ -215,6 +224,11 @@ CREATE INDEX idx_media_items_title ON media_items(title);
|
||||
CREATE INDEX idx_media_items_author ON media_items(author);
|
||||
CREATE INDEX idx_media_items_library_id ON media_items(library_id);
|
||||
CREATE INDEX idx_media_items_added_by_admin_id ON media_items(added_by_admin_id);
|
||||
CREATE INDEX idx_media_items_genre ON media_items(genre);
|
||||
CREATE INDEX idx_media_items_language ON media_items(language);
|
||||
CREATE INDEX idx_media_items_copyright_year ON media_items(copyright_year);
|
||||
CREATE INDEX idx_media_items_page_count ON media_items(page_count);
|
||||
CREATE INDEX idx_media_items_series ON media_items(series);
|
||||
|
||||
-- Progress and ratings indexes
|
||||
CREATE INDEX idx_reading_progress_media_item_id ON reading_progress(media_item_id);
|
||||
@@ -232,6 +246,16 @@ CREATE INDEX idx_media_highlights_note_id ON media_highlights(note_id);
|
||||
-- Add comment explaining the rating system
|
||||
COMMENT ON COLUMN media_ratings.rating IS 'Rating scale 1-10 (odd numbers = half-stars: 1,3,5,7,9 = 0.5,1.5,2.5,3.5,4.5 stars)';
|
||||
|
||||
-- Enhanced metadata comments
|
||||
COMMENT ON COLUMN media_items.language IS 'ISO 639-1 language code (e.g., en, es, fr)';
|
||||
COMMENT ON COLUMN media_items.copyright_year IS 'Copyright or publication year for filtering/sorting';
|
||||
COMMENT ON COLUMN media_items.page_count IS 'Total page count for progress tracking and sorting';
|
||||
COMMENT ON COLUMN media_items.genre IS 'Genre classification for filtering and discovery';
|
||||
COMMENT ON COLUMN media_items.edition IS 'Edition information (e.g., "First Edition", "Revised Edition")';
|
||||
COMMENT ON COLUMN media_items.goodreads_id IS 'Goodreads book identifier for integration';
|
||||
COMMENT ON COLUMN media_items.openlibrary_id IS 'Open Library identifier for integration';
|
||||
COMMENT ON COLUMN media_items.google_books_id IS 'Google Books identifier for integration';
|
||||
|
||||
-- Library Type File Extensions Notes:
|
||||
-- - Ebooks: .epub, .pdf, .mobi, .azw, .azw3, .txt, .rtf, .doc, .docx, .lit, .fb2, .pdb
|
||||
-- - Comics: .cbz, .cbr, .cb7, .cbt, .pdf
|
||||
|
||||
Reference in New Issue
Block a user