another DB table
This commit is contained in:
+42
-11
@@ -1,20 +1,51 @@
|
|||||||
# NFOGuard Development Summary
|
# NFOGuard Development Summary
|
||||||
|
|
||||||
## Current Status: v1.3.2 - Path Mapping Fix & Database Migration
|
## Current Status: v1.3.4 - Complete Database Migration Fix
|
||||||
|
|
||||||
### Latest Updates (v1.3.2)
|
### Latest Updates (v1.3.4)
|
||||||
- **🐛 CRITICAL**: Fixed path mapping bug converting `movies6` to `movies/6`
|
- **🔧 DATABASE**: Fixed comprehensive schema migration for all missing columns
|
||||||
- **🔧 DATABASE**: Added automatic migration for `has_video_file` columns
|
- **✅ MIGRATION**: Added automatic detection and addition of `path`, `has_video_file`, `last_updated` columns
|
||||||
- **🎯 PATH CONFIG**: Removed all hardcoded paths - fully configurable via environment
|
- **🎯 ROBUST**: Schema introspection ensures all required columns exist
|
||||||
- **📝 VALIDATION**: Enhanced path validation in webhook processing
|
- **🔍 VALIDATION**: Comprehensive column checking for both movies and episodes tables
|
||||||
- **🔍 DEBUG**: Added debug logging to path mapper for troubleshooting
|
|
||||||
|
|
||||||
### Path Mapping Logic (Fixed)
|
### Database Migration Strategy
|
||||||
|
```
|
||||||
|
✅ Check existing schema with PRAGMA table_info()
|
||||||
|
✅ Add missing columns: path, has_video_file, last_updated
|
||||||
|
✅ Update existing records with default values
|
||||||
|
✅ Handle both movies and episodes tables
|
||||||
|
✅ Graceful migration without data loss
|
||||||
|
```
|
||||||
|
|
||||||
|
### Path Mapping Success (v1.3.2-v1.3.4)
|
||||||
|
- **🐛 CRITICAL**: Fixed substring matching bug (movies/movies6, tv/tv6)
|
||||||
|
- **🎯 ALGORITHM**: Longest-path-first matching prevents incorrect mappings
|
||||||
|
- **📝 DEBUG**: Comprehensive debug logging for troubleshooting
|
||||||
|
- **✅ TESTED**: Annabelle webhook processes correctly through all stageslopment Summary
|
||||||
|
|
||||||
|
## Current Status: v1.3.3 - Database Migration & Path Validation Complete
|
||||||
|
|
||||||
|
### Latest Updates (v1.3.3)
|
||||||
|
- **� DATABASE**: Fixed missing `path` column migration in movies table
|
||||||
|
- **✅ MIGRATION**: Automatic schema updates with graceful error handling
|
||||||
|
- **🔍 VALIDATION**: Enhanced database migration with column existence checks
|
||||||
|
- **🎯 COMPATIBILITY**: Backward compatibility with existing databases maintained
|
||||||
|
|
||||||
|
### Path Mapping Success (v1.3.2-v1.3.3)
|
||||||
|
- **🐛 CRITICAL**: Fixed substring matching bug (movies/movies6, tv/tv6)
|
||||||
|
- **🎯 ALGORITHM**: Longest-path-first matching prevents incorrect mappings
|
||||||
|
- **� DEBUG**: Comprehensive debug logging for troubleshooting
|
||||||
|
- **✅ TESTED**: Annabelle webhook now processes correctly
|
||||||
|
|
||||||
|
### Working Path Mapping Example
|
||||||
```
|
```
|
||||||
Radarr webhook: /mnt/unionfs/Media/Movies/movies6/Annabelle...
|
Radarr webhook: /mnt/unionfs/Media/Movies/movies6/Annabelle...
|
||||||
↓ Match RADARR_ROOT_FOLDERS[1]: /mnt/unionfs/Media/Movies/movies6
|
✅ Sort by length: [movies6, movies] (longest first)
|
||||||
↓ Map to MOVIE_PATHS[1]: /media/Movies/movies6
|
✅ Match movies6: /mnt/unionfs/Media/Movies/movies6
|
||||||
✅ Result: /media/Movies/movies6/Annabelle...
|
✅ Map to index 1: /media/Movies/movies6
|
||||||
|
✅ Result: /media/Movies/movies6/Annabelle (2014) [tt3322940]
|
||||||
|
✅ Path exists: Validation passes
|
||||||
|
✅ Processing: Movie webhook succeeds
|
||||||
```
|
```
|
||||||
|
|
||||||
### Environment Configuration Required
|
### Environment Configuration Required
|
||||||
|
|||||||
+23
-20
@@ -97,29 +97,32 @@ class NFOGuardDatabase:
|
|||||||
""")
|
""")
|
||||||
|
|
||||||
# Add missing columns if they don't exist (migration)
|
# Add missing columns if they don't exist (migration)
|
||||||
try:
|
# Check current schema and add missing columns
|
||||||
cursor.execute("ALTER TABLE episodes ADD COLUMN has_video_file BOOLEAN DEFAULT FALSE")
|
|
||||||
except sqlite3.OperationalError:
|
|
||||||
# Column already exists
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
cursor.execute("ALTER TABLE movies ADD COLUMN has_video_file BOOLEAN DEFAULT FALSE")
|
|
||||||
except sqlite3.OperationalError:
|
|
||||||
# Column already exists
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Check if movies table has path column, add if missing
|
|
||||||
cursor.execute("PRAGMA table_info(movies)")
|
cursor.execute("PRAGMA table_info(movies)")
|
||||||
columns = [row[1] for row in cursor.fetchall()]
|
movie_columns = [row[1] for row in cursor.fetchall()]
|
||||||
if 'path' not in columns:
|
|
||||||
|
cursor.execute("PRAGMA table_info(episodes)")
|
||||||
|
episode_columns = [row[1] for row in cursor.fetchall()]
|
||||||
|
|
||||||
|
# Add missing columns to movies table
|
||||||
|
if 'path' not in movie_columns:
|
||||||
cursor.execute("ALTER TABLE movies ADD COLUMN path TEXT")
|
cursor.execute("ALTER TABLE movies ADD COLUMN path TEXT")
|
||||||
# Update existing records with a placeholder path
|
|
||||||
cursor.execute("UPDATE movies SET path = '/unknown/path/' || imdb_id WHERE path IS NULL")
|
cursor.execute("UPDATE movies SET path = '/unknown/path/' || imdb_id WHERE path IS NULL")
|
||||||
|
|
||||||
# Make path NOT NULL after adding it
|
if 'has_video_file' not in movie_columns:
|
||||||
# Note: SQLite doesn't support ALTER COLUMN, so we'd need to recreate table
|
cursor.execute("ALTER TABLE movies ADD COLUMN has_video_file BOOLEAN DEFAULT FALSE")
|
||||||
# For now, just ensure new records have paths
|
|
||||||
|
if 'last_updated' not in movie_columns:
|
||||||
|
cursor.execute("ALTER TABLE movies ADD COLUMN last_updated TEXT")
|
||||||
|
cursor.execute("UPDATE movies SET last_updated = datetime('now') WHERE last_updated IS NULL")
|
||||||
|
|
||||||
|
# Add missing columns to episodes table
|
||||||
|
if 'has_video_file' not in episode_columns:
|
||||||
|
cursor.execute("ALTER TABLE episodes ADD COLUMN has_video_file BOOLEAN DEFAULT FALSE")
|
||||||
|
|
||||||
|
if 'last_updated' not in episode_columns:
|
||||||
|
cursor.execute("ALTER TABLE episodes ADD COLUMN last_updated TEXT")
|
||||||
|
cursor.execute("UPDATE episodes SET last_updated = datetime('now') WHERE last_updated IS NULL")
|
||||||
|
|
||||||
# Create indexes
|
# Create indexes
|
||||||
cursor.execute("CREATE INDEX IF NOT EXISTS idx_episodes_imdb ON episodes(imdb_id)")
|
cursor.execute("CREATE INDEX IF NOT EXISTS idx_episodes_imdb ON episodes(imdb_id)")
|
||||||
|
|||||||
Reference in New Issue
Block a user