mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-03 13:18:32 -04:00
Merge branch 'cycle-notification_history-table' of github.com:alphagov/notifications-api into cycle-notification_history-table
This commit is contained in:
@@ -372,6 +372,14 @@ def insert_notification_history_delete_notifications(
|
||||
ON CONFLICT ON CONSTRAINT notification_history_pkey
|
||||
DO NOTHING
|
||||
"""
|
||||
# Insert data into the pivot table as well. Only needed while we are trying to cycle the history table.
|
||||
insert_pivot_query = """
|
||||
insert into notification_history_pivot
|
||||
SELECT * from NOTIFICATION_ARCHIVE
|
||||
ON CONFLICT ON CONSTRAINT notification_history_pivot_pkey
|
||||
DO NOTHING
|
||||
"""
|
||||
|
||||
delete_query = """
|
||||
DELETE FROM notifications
|
||||
where id in (select id from NOTIFICATION_ARCHIVE)
|
||||
@@ -390,6 +398,8 @@ def insert_notification_history_delete_notifications(
|
||||
|
||||
db.session.execute(insert_query)
|
||||
|
||||
db.session.execute(insert_pivot_query)
|
||||
|
||||
db.session.execute(delete_query)
|
||||
|
||||
db.session.execute("DROP TABLE NOTIFICATION_ARCHIVE")
|
||||
|
||||
Reference in New Issue
Block a user