fix(offset): only suggest episode_offset for virtual seasons

- Change episode_offset type from int to int | None
- Only set episode_offset when virtual season split is detected
- For simple season mismatches (e.g., RSS S2 → TMDB S1), episode_offset is now None
- Improve reason messages to clarify when episode offset is/isn't needed
- Update database migration version to 7 and add migration check

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
EstrellaXD
2026-01-26 13:51:55 +01:00
parent 01a1a79a33
commit 3c71cf813f
2 changed files with 35 additions and 11 deletions

View File

@@ -23,7 +23,7 @@ logger = logging.getLogger(__name__)
TABLE_MODELS: list[type[SQLModel]] = [Bangumi, RSSItem, Torrent, User, Passkey]
# Increment this when adding new migrations to MIGRATIONS list.
CURRENT_SCHEMA_VERSION = 6
CURRENT_SCHEMA_VERSION = 7
# Each migration is a tuple of (version, description, list of SQL statements).
# Migrations are applied in order. A migration at index i brings the schema
@@ -183,6 +183,10 @@ class Database(Session):
columns = [col["name"] for col in inspector.get_columns("torrent")]
if "qb_hash" in columns:
needs_run = False
if "bangumi" in tables and version == 7:
columns = [col["name"] for col in inspector.get_columns("bangumi")]
if "suggested_season_offset" in columns:
needs_run = False
if needs_run:
with self.engine.connect() as conn:
for stmt in statements: