#!/usr/bin/env python3
"""
Create assistant tables for EPOLaw AI Assistant feature
"""
from app import app
from models import db, AssistantConversation, AssistantMessage

def create_assistant_tables():
    """Create assistant conversation and message tables"""
    with app.app_context():
        # Create the tables
        print("Creating assistant tables...")

        try:
            # Create tables
            db.create_all()
            print("✅ Assistant tables created successfully!")

            # Verify tables exist
            from sqlalchemy import inspect
            inspector = inspect(db.engine)

            tables = inspector.get_table_names()

            if 'assistant_conversations' in tables:
                print("✅ assistant_conversations table exists")
            else:
                print("❌ assistant_conversations table NOT found")

            if 'assistant_messages' in tables:
                print("✅ assistant_messages table exists")
            else:
                print("❌ assistant_messages table NOT found")

            print("\nTable creation complete!")

        except Exception as e:
            print(f"❌ Error creating tables: {e}")
            import traceback
            traceback.print_exc()

if __name__ == '__main__':
    create_assistant_tables()
