update DB tables
This commit is contained in:
+14
-3
@@ -43,7 +43,7 @@ class NFOGuardDatabase:
|
||||
raise
|
||||
|
||||
def _init_database(self):
|
||||
"""Initialize database tables"""
|
||||
"""Initialize database tables with migration support"""
|
||||
with self.get_connection() as conn:
|
||||
cursor = conn.cursor()
|
||||
|
||||
@@ -66,7 +66,6 @@ class NFOGuardDatabase:
|
||||
aired TEXT,
|
||||
dateadded TEXT,
|
||||
source TEXT,
|
||||
has_video_file BOOLEAN DEFAULT FALSE,
|
||||
last_updated TEXT NOT NULL,
|
||||
PRIMARY KEY (imdb_id, season, episode),
|
||||
FOREIGN KEY (imdb_id) REFERENCES series(imdb_id)
|
||||
@@ -81,7 +80,6 @@ class NFOGuardDatabase:
|
||||
released TEXT,
|
||||
dateadded TEXT,
|
||||
source TEXT,
|
||||
has_video_file BOOLEAN DEFAULT FALSE,
|
||||
last_updated TEXT NOT NULL
|
||||
)
|
||||
""")
|
||||
@@ -98,6 +96,19 @@ class NFOGuardDatabase:
|
||||
)
|
||||
""")
|
||||
|
||||
# Add has_video_file columns if they don't exist (migration)
|
||||
try:
|
||||
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
|
||||
|
||||
# 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_video ON episodes(has_video_file)")
|
||||
|
||||
Reference in New Issue
Block a user