From 4b9a7069acded71ec837a390a58a585c395ef86a Mon Sep 17 00:00:00 2001 From: Xoconoch Date: Sat, 23 Aug 2025 10:41:58 -0600 Subject: [PATCH] feat(migration): Added migration script for 3.2.1 -> 3.2.2 --- routes/migrations/runner.py | 8 +++++--- routes/migrations/v3_2_0.py | 12 +++++------ routes/migrations/v3_2_1.py | 41 +++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 routes/migrations/v3_2_1.py diff --git a/routes/migrations/runner.py b/routes/migrations/runner.py index 820ac28..ae25275 100644 --- a/routes/migrations/runner.py +++ b/routes/migrations/runner.py @@ -4,6 +4,7 @@ from pathlib import Path from typing import Optional from .v3_2_0 import MigrationV3_2_0 +from .v3_2_1 import log_noop_migration_detected logger = logging.getLogger(__name__) @@ -379,10 +380,10 @@ def run_migrations_if_needed(): with _safe_connect(HISTORY_DB) as history_conn: if history_conn and not _is_history_at_least_3_2_0(history_conn): logger.error( - "Instance is not at schema version 3.2.0. Please upgrade to 3.2.0 before applying 3.2.1." + "Instance is not at schema version 3.2.0. Please upgrade to 3.2.0 before applying 3.2.2." ) raise RuntimeError( - "Instance is not at schema version 3.2.0. Please upgrade to 3.2.0 before applying 3.2.1." + "Instance is not at schema version 3.2.0. Please upgrade to 3.2.0 before applying 3.2.2." ) # Watch playlists DB @@ -413,4 +414,5 @@ def run_migrations_if_needed(): raise else: _ensure_creds_filesystem() - logger.info("Database migrations check completed (3.2.0 -> 3.2.1 path)") + log_noop_migration_detected() + logger.info("Database migrations check completed (3.2.0 -> 3.2.2 path)") diff --git a/routes/migrations/v3_2_0.py b/routes/migrations/v3_2_0.py index 4307bec..f6953ce 100644 --- a/routes/migrations/v3_2_0.py +++ b/routes/migrations/v3_2_0.py @@ -6,7 +6,7 @@ logger = logging.getLogger(__name__) class MigrationV3_2_0: """ - Migration for version 3.2.0 (upgrade path 3.2.0 -> 3.2.1). + Migration for version 3.2.0 (upgrade path 3.2.0 -> 3.2.2). - Adds per-item batch progress columns to Watch DBs to support page-by-interval processing. - Enforces prerequisite: previous instance version must be 3.1.2 (validated by runner). """ @@ -21,7 +21,7 @@ class MigrationV3_2_0: "batch_next_offset": "INTEGER DEFAULT 0", } - # --- No-op for history/accounts in 3.2.1 --- + # --- No-op for history/accounts in 3.2.2 --- def check_history(self, conn: sqlite3.Connection) -> bool: return True @@ -59,14 +59,14 @@ class MigrationV3_2_0: f"ALTER TABLE watched_playlists ADD COLUMN {col_name} {col_type}" ) logger.info( - f"Added column '{col_name} {col_type}' to watched_playlists for 3.2.1 batch progress." + f"Added column '{col_name} {col_type}' to watched_playlists for 3.2.2 batch progress." ) except sqlite3.OperationalError as e: logger.warning( f"Could not add column '{col_name}' to watched_playlists: {e}" ) except Exception: - logger.error("Failed to update watched_playlists for 3.2.1", exc_info=True) + logger.error("Failed to update watched_playlists for 3.2.2", exc_info=True) # --- Watch: artists --- @@ -90,11 +90,11 @@ class MigrationV3_2_0: f"ALTER TABLE watched_artists ADD COLUMN {col_name} {col_type}" ) logger.info( - f"Added column '{col_name} {col_type}' to watched_artists for 3.2.1 batch progress." + f"Added column '{col_name} {col_type}' to watched_artists for 3.2.2 batch progress." ) except sqlite3.OperationalError as e: logger.warning( f"Could not add column '{col_name}' to watched_artists: {e}" ) except Exception: - logger.error("Failed to update watched_artists for 3.2.1", exc_info=True) + logger.error("Failed to update watched_artists for 3.2.2", exc_info=True) diff --git a/routes/migrations/v3_2_1.py b/routes/migrations/v3_2_1.py new file mode 100644 index 0000000..6f7716b --- /dev/null +++ b/routes/migrations/v3_2_1.py @@ -0,0 +1,41 @@ +import logging +import sqlite3 + +logger = logging.getLogger(__name__) + + +class MigrationV3_2_1: + """ + No-op migration for version 3.2.1 (upgrade path 3.2.1 -> 3.2.2). + No database schema changes are required. + """ + + def check_history(self, conn: sqlite3.Connection) -> bool: + return True + + def update_history(self, conn: sqlite3.Connection) -> None: + pass + + def check_accounts(self, conn: sqlite3.Connection) -> bool: + return True + + def update_accounts(self, conn: sqlite3.Connection) -> None: + pass + + def check_watch_playlists(self, conn: sqlite3.Connection) -> bool: + return True + + def update_watch_playlists(self, conn: sqlite3.Connection) -> None: + pass + + def check_watch_artists(self, conn: sqlite3.Connection) -> bool: + return True + + def update_watch_artists(self, conn: sqlite3.Connection) -> None: + pass + + +def log_noop_migration_detected() -> None: + logger.info( + "No migration performed: detected schema for 3.2.1; no changes needed for 3.2.1 -> 3.2.2." + )