fix(video): move idx_movies_collection to _POST_INDEXES (broke DB init)
The new index on movies.tmdb_collection_id was in video_schema.sql, which executescript runs BEFORE _ensure_columns adds the column on existing DBs — so 'CREATE INDEX ... ON movies(tmdb_collection_id)' failed with 'no such column' and the whole video DB init aborted (500s on every /api/video/* call). Moved the index to _POST_INDEXES (runs after the ALTERs), matching the pattern the code comments already prescribe. The CREATE TABLE columns stay (fresh DBs) + the ALTER migration stays (existing DBs); only the index moved.
This commit is contained in:
parent
a8ce359cb7
commit
78874313cc
2 changed files with 5 additions and 1 deletions
|
|
@ -302,6 +302,9 @@ class VideoDatabase:
|
||||||
"ON video_wishlist(source_id) WHERE kind = 'video'",
|
"ON video_wishlist(source_id) WHERE kind = 'video'",
|
||||||
"CREATE INDEX IF NOT EXISTS idx_video_wishlist_channel "
|
"CREATE INDEX IF NOT EXISTS idx_video_wishlist_channel "
|
||||||
"ON video_wishlist(parent_source_id) WHERE kind = 'video'",
|
"ON video_wishlist(parent_source_id) WHERE kind = 'video'",
|
||||||
|
# Index on movies.tmdb_collection_id — a migration-added column, so it must be
|
||||||
|
# created AFTER _ensure_columns (the schema executescript runs before the ALTERs).
|
||||||
|
"CREATE INDEX IF NOT EXISTS idx_movies_collection ON movies(tmdb_collection_id)",
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,9 @@ CREATE TABLE IF NOT EXISTS movies (
|
||||||
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
|
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
);
|
);
|
||||||
CREATE INDEX IF NOT EXISTS idx_movies_tmdb ON movies(tmdb_id);
|
CREATE INDEX IF NOT EXISTS idx_movies_tmdb ON movies(tmdb_id);
|
||||||
CREATE INDEX IF NOT EXISTS idx_movies_collection ON movies(tmdb_collection_id);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_movies_monitored ON movies(monitored, has_file);
|
CREATE INDEX IF NOT EXISTS idx_movies_monitored ON movies(monitored, has_file);
|
||||||
|
-- NOTE: idx on tmdb_collection_id (a migration-added column) lives in _POST_INDEXES,
|
||||||
|
-- not here — this schema runs BEFORE the ALTER that adds the column on upgraded DBs.
|
||||||
CREATE INDEX IF NOT EXISTS idx_movies_release ON movies(release_date);
|
CREATE INDEX IF NOT EXISTS idx_movies_release ON movies(release_date);
|
||||||
-- Upsert/stale-removal key: the server's native id. Multiple NULLs are allowed
|
-- Upsert/stale-removal key: the server's native id. Multiple NULLs are allowed
|
||||||
-- (wishlist items not yet on a server), so this never blocks non-server rows.
|
-- (wishlist items not yet on a server), so this never blocks non-server rows.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue