customeragent-api / server /scripts /fix_website_schema.py
anasraza526's picture
Clean deploy to Hugging Face
ac90985
#!/usr/bin/env python3
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from sqlalchemy import create_engine, text
from app.core.config import settings
def fix_website_schema():
print(f"Connecting to database: {settings.DATABASE_URL}")
engine = create_engine(settings.DATABASE_URL)
with engine.connect() as conn:
try:
# Check if tone column exists
check_query = text("""
SELECT column_name
FROM information_schema.columns
WHERE table_name='websites' AND column_name='tone';
""")
result = conn.execute(check_query).fetchone()
if not result:
print("Column 'tone' not found in 'websites' table. Adding it...")
conn.execute(text("ALTER TABLE websites ADD COLUMN tone VARCHAR"))
conn.commit()
print("Successfully added 'tone' column to 'websites' table.")
else:
print("Column 'tone' already exists in 'websites' table.")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
fix_website_schema()