diff --git a/backend/delete_hina_invitation.py b/backend/delete_hina_invitation.py new file mode 100644 index 0000000..0251cd2 --- /dev/null +++ b/backend/delete_hina_invitation.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +""" +Delete the custom hina_invitation template from the database. +This allows us to recreate it with the correct button configuration. +""" + +import os +import sys +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker + +# Import database config +from database import DATABASE_URL, Base +from models import WhatsAppTemplate + +def delete_hina(): + """Delete custom hina_invitation template from database.""" + + # Create engine and session + engine = create_engine(DATABASE_URL) + SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) + db = SessionLocal() + + try: + # Find and delete hina_invitation + template = db.query(WhatsAppTemplate).filter( + WhatsAppTemplate.template_key == 'hina_invitation' + ).first() + + if template: + print(f"✓ Found custom 'hina_invitation' in database") + print(f" - meta_name: {template.meta_name}") + print(f" - body_params: {template.body_params}") + + db.delete(template) + db.commit() + print(f"✓ Deleted custom 'hina_invitation'") + print(f"✓ Ready to create corrected version") + else: + print(f"✓ No custom 'hina_invitation' found (already deleted or doesn't exist)") + + except Exception as e: + print(f"✗ Error: {e}") + db.rollback() + sys.exit(1) + finally: + db.close() + +if __name__ == "__main__": + delete_hina()