#!/usr/bin/env python3 """ Script to recreate database tables with updated schema """ from database import engine, Base from sqlalchemy import text import logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) def recreate_tables(): """Drop and recreate all tables""" try: with engine.connect() as connection: # Drop existing tables logger.info("Dropping existing tables...") connection.execute(text("DROP TABLE IF EXISTS messages CASCADE")) connection.execute(text("DROP TABLE IF EXISTS transactions CASCADE")) connection.commit() logger.info("āœ“ Tables dropped") # Create new tables with updated schema logger.info("Creating new tables...") Base.metadata.create_all(bind=engine) logger.info("āœ“ Tables created with updated schema") print("\nšŸŽ‰ Database tables recreated successfully!") print("The plugin should now work with optional item_id and amount fields.") except Exception as e: logger.error(f"Error recreating tables: {e}") return False return True if __name__ == "__main__": print("Recreating database tables with updated schema...") recreate_tables()