Files
nike/scripts/apply_schema.py
Robert Helewka 62af6727e6
All checks were successful
CVE Scan & Docker Build / security-scan (push) Successful in 42s
CVE Scan & Docker Build / build-and-push (push) Successful in 1m20s
feat: migrate from RapidAPI to TheSportsDB with SvelteKit dashboard
- Replace free-api-live-football-data (RapidAPI) backend with TheSportsDB
- Add PostgreSQL cache layer for permanent data (teams, players, leagues, events)
- Replace Bootstrap dashboard with SvelteKit-based interactive dashboard
- Restructure MCP tools around TheSportsDB capabilities (get_team_info, get_roster, get_fixtures, get_standings, etc.)
- Expose tool registry via GET /api/tools so dashboard stays in sync
- Remove legacy modules and references (api_football, sync, RapidAPI env vars)
2026-06-11 10:22:24 -04:00

49 lines
1.0 KiB
Python

#!/usr/bin/env python3
"""Apply the Nike cache schema (schema.sql) to PostgreSQL."""
import os
import sys
import psycopg2
from nike import config
try:
conn = psycopg2.connect(
host=config.DB_HOST,
port=config.DB_PORT,
user=config.DB_USER,
password=config.DB_PASSWORD,
dbname=config.DB_NAME,
)
except Exception as e:
print(f"❌ Cannot connect to DB: {e}")
sys.exit(1)
conn.autocommit = True
cur = conn.cursor()
schema_path = os.path.join(os.path.dirname(__file__), '..', 'schema.sql')
with open(schema_path, 'r') as f:
sql = f.read()
try:
cur.execute(sql)
print("✅ Schema applied successfully.")
except Exception as e:
print(f"❌ Schema error: {e}")
cur.close()
conn.close()
sys.exit(1)
cur.execute("""
SELECT table_name FROM information_schema.tables
WHERE table_schema = 'public' ORDER BY table_name;
""")
tables = cur.fetchall()
print(f" {len(tables)} tables in public schema:")
for t in tables:
print(f"{t[0]}")
cur.close()
conn.close()