Spaces:
Runtime error
Runtime error
Download database/migrate.py from spark-ds549/BPL-RAG-Spring-2026: direct link, hf CLI and curl.
- Browser
- Download file 835 Bytes
-
https://huggingface.co/spaces/spark-ds549/BPL-RAG-Spring-2026/resolve/main/database/migrate.py
- Command line
-
hf download hf://spaces/spark-ds549/BPL-RAG-Spring-2026/database/migrate.py
-
curl -L -o migrate.py https://huggingface.co/spaces/spark-ds549/BPL-RAG-Spring-2026/resolve/main/database/migrate.py
835 Bytes
| """ | |
| database/migrate.py | |
| Runs database/migrations.sql against the configured Postgres (Railway). | |
| Idempotent — uses IF NOT EXISTS / ADD COLUMN IF NOT EXISTS throughout. | |
| Run once after pulling the human-in-the-loop changes: | |
| python -m database.migrate | |
| """ | |
| from __future__ import annotations | |
| from pathlib import Path | |
| from database.schema import get_conn, get_cursor | |
| SQL_PATH = Path(__file__).parent / "migrations.sql" | |
| def run_migrations() -> None: | |
| sql = SQL_PATH.read_text() | |
| print(f"[migrate] applying {SQL_PATH.name} ...") | |
| with get_conn() as conn: | |
| with get_cursor(conn) as cur: | |
| cur.execute(sql) | |
| print("[migrate] done. Added: query_logs.{session_id,retrieved_docs," | |
| "source_titles,source_urls,parent_query_id}, table feedback.") | |
| if __name__ == "__main__": | |
| run_migrations() | |