diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index cbde45d30..bbb355bbe 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -1,7 +1,7 @@ from datetime import timedelta from flask import current_app -from sqlalchemy import asc, delete, desc, func, or_, select, text, union, update +from sqlalchemy import asc, delete, desc, func, insert, or_, select, text, union, update from sqlalchemy.orm import joinedload from sqlalchemy.orm.exc import NoResultFound from sqlalchemy.sql import functions @@ -71,7 +71,11 @@ def dao_create_notification(notification): # notify-api-742 remove phone numbers from db notification.to = "1" notification.normalised_to = "1" - db.session.add(notification) + stmt = ( + insert(Notification).values(notification.serialize()).on_conflict_do_nothing() + ) + db.session.execute(stmt) + db.session.commit() def country_records_delivery(phone_prefix):