feat: add geolocation to download logs (country, city via ip-api.com)
This commit is contained in:
@@ -32,3 +32,13 @@ async def init_db():
|
||||
await conn.execute(text(
|
||||
"CREATE INDEX IF NOT EXISTS ix_download_logs_downloaded_at ON download_logs (downloaded_at)"
|
||||
))
|
||||
# Migrate: add geo columns to existing download_logs table (idempotent)
|
||||
for col_def in [
|
||||
"ALTER TABLE download_logs ADD COLUMN country_code VARCHAR(8) DEFAULT ''",
|
||||
"ALTER TABLE download_logs ADD COLUMN country VARCHAR(128) DEFAULT ''",
|
||||
"ALTER TABLE download_logs ADD COLUMN city VARCHAR(128) DEFAULT ''",
|
||||
]:
|
||||
try:
|
||||
await conn.execute(text(col_def))
|
||||
except Exception:
|
||||
pass # Column already exists
|
||||
|
||||
Reference in New Issue
Block a user