mirror of
https://github.com/GSA/notifications-api.git
synced 2026-03-13 06:40:45 -04:00
Trying to find an efficient way to cycle the data
This commit is contained in:
@@ -6,15 +6,6 @@ ALTER TABLE notification_history_pivot ADD CONSTRAINT notification_history_key_t
|
||||
ALTER TABLE notification_history_pivot ADD CONSTRAINT notification_history_service_id_fkey FOREIGN KEY (service_id) REFERENCES services(id)
|
||||
ALTER TABLE notification_history_pivot ADD CONSTRAINT notification_history_templates_history_fkey FOREIGN KEY (template_id, template_version) REFERENCES templates_history(id, version)
|
||||
|
||||
-- we could possibly not create this check constraint in the new table since we want to drop it in an outstanding PR.
|
||||
ALTER TABLE notification_history_pivot ADD CONSTRAINT chk_notification_history_postage_null CHECK (
|
||||
CASE
|
||||
WHEN notification_type = 'letter'::notification_type
|
||||
THEN postage IS NOT NULL AND (postage::text = ANY (ARRAY['first'::character varying, 'second'::character varying]::text[]))
|
||||
ELSE postage IS NULL
|
||||
END)
|
||||
|
||||
|
||||
--- Create indexes after drop table since the names need to be unique
|
||||
--- Or rename these indexes (index names have to be unique in db)
|
||||
CREATE INDEX CONCURRENTLY ix_notification_history_job_id ON notification_history_pivot (job_id);
|
||||
@@ -22,6 +13,14 @@ CREATE INDEX CONCURRENTLY ix_notification_history_reference ON notification_hist
|
||||
CREATE INDEX CONCURRENTLY ix_notification_history_template_id ON notification_history_pivot (template_id);
|
||||
CREATE INDEX CONCURRENTLY ix_notifications_service_id_composite ON notification_history_pivot (service_id, key_type, notification_type, created_at);
|
||||
|
||||
-- we could possibly not create this check constraint in the new table since we want to drop it in an outstanding PR.
|
||||
--ALTER TABLE notification_history_pivot ADD CONSTRAINT chk_notification_history_postage_null CHECK (
|
||||
--CASE
|
||||
-- WHEN notification_type = 'letter'::notification_type
|
||||
-- THEN postage IS NOT NULL AND (postage::text = ANY (ARRAY['first'::character varying, 'second'::character varying]::text[]))
|
||||
-- ELSE postage IS NULL
|
||||
--END)
|
||||
|
||||
-- Not creating these ones since we want to drop them any way.
|
||||
--DROP INDEX CONCURRENTLY ix_notification_history_api_key_id;
|
||||
--DROP INDEX CONCURRENTLY ix_notification_history_created_at;
|
||||
|
||||
Reference in New Issue
Block a user