""" Add email_verification_code column to users table """ import psycopg2 import os def run_migration(): """Add email_verification_code field to users table""" # Get database connection info from environment db_url = os.getenv('DATABASE_URL', 'postgresql://localhost/speechpathai_dev') try: # Connect to PostgreSQL conn = psycopg2.connect(db_url) cur = conn.cursor() print("Connected to PostgreSQL database") # Add verification code column try: cur.execute(""" ALTER TABLE users ADD COLUMN IF NOT EXISTS email_verification_code VARCHAR """) print("✓ Added email_verification_code column") except Exception as e: print(f"Column email_verification_code might already exist: {e}") # Commit changes conn.commit() print("✓ Migration completed successfully!") except Exception as e: print(f"Error: {e}") if 'conn' in locals(): conn.rollback() finally: if 'cur' in locals(): cur.close() if 'conn' in locals(): conn.close() if __name__ == "__main__": run_migration()