invy/backend/delete_hina_invitation.py
dvirlabs 5c4bb0d3fa
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Update hina template
2026-05-14 14:47:46 +03:00

51 lines
1.5 KiB
Python

#!/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()