mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-25 08:43:55 -04:00
This is a place to start creating scripts for maintaining the database.
This commit is contained in:
28
database_maintenance/create_temp_notification_history.sql
Normal file
28
database_maintenance/create_temp_notification_history.sql
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
--- Just a holding place to create a table to cycle the Notification history table
|
||||||
|
create table temp_notification_history (
|
||||||
|
id | uuid | not null
|
||||||
|
job_id | uuid |
|
||||||
|
job_row_number | integer |
|
||||||
|
service_id | uuid |
|
||||||
|
template_id | uuid |
|
||||||
|
template_version | integer | not null
|
||||||
|
api_key_id | uuid |
|
||||||
|
key_type | character varying | not null
|
||||||
|
notification_type | notification_type | not null
|
||||||
|
created_at | timestamp without time zone | not null
|
||||||
|
sent_at | timestamp without time zone |
|
||||||
|
sent_by | character varying |
|
||||||
|
updated_at | timestamp without time zone |
|
||||||
|
reference | character varying |
|
||||||
|
billable_units | integer | not null
|
||||||
|
client_reference | character varying |
|
||||||
|
international | boolean |
|
||||||
|
phone_prefix | character varying |
|
||||||
|
rate_multiplier | numeric |
|
||||||
|
notification_status | text |
|
||||||
|
created_by_id | uuid |
|
||||||
|
postage | character varying |
|
||||||
|
document_download_count | integer |
|
||||||
|
|
||||||
|
)
|
||||||
|
with indexes
|
||||||
36
database_maintenance/cycle_notification_history.sql
Normal file
36
database_maintenance/cycle_notification_history.sql
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
create table temp_notification_history (
|
||||||
|
id | uuid | not null
|
||||||
|
job_id | uuid |
|
||||||
|
job_row_number | integer |
|
||||||
|
service_id | uuid |
|
||||||
|
template_id | uuid |
|
||||||
|
template_version | integer | not null
|
||||||
|
api_key_id | uuid |
|
||||||
|
key_type | character varying | not null
|
||||||
|
notification_type | notification_type | not null
|
||||||
|
created_at | timestamp without time zone | not null
|
||||||
|
sent_at | timestamp without time zone |
|
||||||
|
sent_by | character varying |
|
||||||
|
updated_at | timestamp without time zone |
|
||||||
|
reference | character varying |
|
||||||
|
billable_units | integer | not null
|
||||||
|
client_reference | character varying |
|
||||||
|
international | boolean |
|
||||||
|
phone_prefix | character varying |
|
||||||
|
rate_multiplier | numeric |
|
||||||
|
notification_status | text |
|
||||||
|
created_by_id | uuid |
|
||||||
|
postage | character varying |
|
||||||
|
document_download_count | integer |
|
||||||
|
|
||||||
|
)
|
||||||
|
with indexes
|
||||||
|
|
||||||
|
create trigger to update temp_notification_history when update to notification_history
|
||||||
|
|
||||||
|
insert data into temp_notification_history in batches
|
||||||
|
|
||||||
|
drop table notification_history;
|
||||||
|
--- potential for data loss in this step.
|
||||||
|
rename table temp_notification_history to notification_history;
|
||||||
Reference in New Issue
Block a user