feat: track download logs (ip, browser, device, time)
This commit is contained in:
@@ -21,9 +21,14 @@ async def get_db():
|
||||
async def init_db():
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
# Ensure composite index exists on already-created tables (idempotent)
|
||||
await conn.execute(
|
||||
__import__("sqlalchemy").text(
|
||||
"CREATE INDEX IF NOT EXISTS ix_video_url_format_id ON videos (url, format_id)"
|
||||
)
|
||||
)
|
||||
# Ensure indexes exist on already-created tables (idempotent)
|
||||
from sqlalchemy import text
|
||||
await conn.execute(text(
|
||||
"CREATE INDEX IF NOT EXISTS ix_video_url_format_id ON videos (url, format_id)"
|
||||
))
|
||||
await conn.execute(text(
|
||||
"CREATE INDEX IF NOT EXISTS ix_download_logs_video_id ON download_logs (video_id)"
|
||||
))
|
||||
await conn.execute(text(
|
||||
"CREATE INDEX IF NOT EXISTS ix_download_logs_downloaded_at ON download_logs (downloaded_at)"
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user