#!/usr/bin/env python3
"""
Create RAG vector DB schema in Postgres (extension + stories, documents, chunks).
Requires RAG_DB_DSN and RAG_EMBEDDINGS_DIM (optional, default 1536).
Run from repo root with package installed: pip install -e . && python scripts/create_db.py
"""
from __future__ import annotations

import sys
from pathlib import Path

# Allow importing rag_agent when run as scripts/create_db.py
repo_root = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(repo_root / "src"))

from rag_agent.config import load_config
from rag_agent.index.postgres import connect, ensure_schema


def main() -> None:
    config = load_config()
    conn = connect(config.db_dsn)
    ensure_schema(conn, config.embeddings_dim)
    conn.close()
    print("Schema created successfully.")


if __name__ == "__main__":
    main()
