File size: 1,100 Bytes
d3e87b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

import os
import sys
from sqlalchemy import create_engine, text

# Add path to find config
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from src.core.config import Config

def create_table():
    print("🔧 Connecting to Cloud DB...")
    config = Config()
    
    try:
        engine = create_engine(config.DB_URL)
        with engine.connect() as conn:
            print("🔨 Creating 'feedback_logs' table...")
            conn.execute(text("""
                CREATE TABLE IF NOT EXISTS feedback_logs (
                    id SERIAL PRIMARY KEY,
                    user_id INTEGER,
                    prompt TEXT,
                    ai_response TEXT,
                    user_correction TEXT,
                    feedback_type TEXT,
                    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
                );
            """))
            conn.commit()
            print("✅ Success! Feedback table is ready in Neon.")
    except Exception as e:
        print(f"❌ DB Error: {e}")

if __name__ == "__main__":
    create_table()