fix: resume from homepage not correctly handling source_id

This commit is contained in:
Trevor Mears
2026-01-22 18:23:48 -08:00
parent e83b173755
commit ac6c82e3fc
3 changed files with 15 additions and 3 deletions
+9
View File
@@ -122,6 +122,7 @@ function initSchema() {
CREATE TABLE IF NOT EXISTS watch_history (
id TEXT PRIMARY KEY, -- Composite key: user_id:item_id
user_id INTEGER NOT NULL,
source_id INTEGER, -- Source ID for Xtream/M3U
item_type TEXT NOT NULL, -- 'movie', 'episode'
item_id TEXT NOT NULL, -- The original item ID (stream_id or composite)
parent_id TEXT, -- For episodes (series ID)
@@ -134,6 +135,14 @@ function initSchema() {
CREATE INDEX IF NOT EXISTS idx_history_user_item ON watch_history(user_id, item_id);
`);
// Migration: Add source_id column if missing (for existing databases)
try {
db.exec(`ALTER TABLE watch_history ADD COLUMN source_id INTEGER`);
console.log('[SQLite] Added source_id column to watch_history');
} catch (e) {
// Column already exists, ignore
}
console.log('[SQLite] Schema initialized');
}