Fix requests cache migration on legacy databases
This commit is contained in:
+10
-6
@@ -418,12 +418,16 @@ def init_db() -> None:
|
|||||||
ON requests_cache (updated_at DESC, request_id DESC)
|
ON requests_cache (updated_at DESC, request_id DESC)
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
conn.execute(
|
try:
|
||||||
"""
|
conn.execute(
|
||||||
CREATE INDEX IF NOT EXISTS idx_requests_cache_requested_by_id_created_at
|
"""
|
||||||
ON requests_cache (requested_by_id, created_at DESC, request_id DESC)
|
CREATE INDEX IF NOT EXISTS idx_requests_cache_requested_by_id_created_at
|
||||||
"""
|
ON requests_cache (requested_by_id, created_at DESC, request_id DESC)
|
||||||
)
|
"""
|
||||||
|
)
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
# Older databases may not have requested_by_id until later migrations run.
|
||||||
|
pass
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"""
|
"""
|
||||||
CREATE INDEX IF NOT EXISTS idx_requests_cache_requested_by_norm_created_at
|
CREATE INDEX IF NOT EXISTS idx_requests_cache_requested_by_norm_created_at
|
||||||
|
|||||||
Reference in New Issue
Block a user