From 83261bdd222f75de98de4e3e860d1f59a6696558 Mon Sep 17 00:00:00 2001 From: Changaco Date: Thu, 5 Mar 2020 14:20:15 +0100 Subject: [PATCH] merge branch.sql --- sql/branch.sql | 11 ----------- sql/migrations.sql | 12 ++++++++++++ sql/schema.sql | 3 ++- 3 files changed, 14 insertions(+), 12 deletions(-) delete mode 100644 sql/branch.sql diff --git a/sql/branch.sql b/sql/branch.sql deleted file mode 100644 index faa7ac03bb..0000000000 --- a/sql/branch.sql +++ /dev/null @@ -1,11 +0,0 @@ -ALTER TABLE email_blacklist ADD COLUMN ignored_by bigint REFERENCES participants; - -UPDATE email_blacklist AS bl - SET ignore_after = current_timestamp - , ignored_by = e.participant - FROM emails e - WHERE lower(e.address) = lower(bl.address) - AND e.verified - AND (bl.ignore_after IS NULL OR bl.ignore_after > current_timestamp) - AND (bl.reason = 'bounce' AND bl.ts < (e.added_time + interval '24 hours') OR - bl.reason = 'complaint' AND bl.details = 'disavowed'); diff --git a/sql/migrations.sql b/sql/migrations.sql index ece0359fb6..014b22a00e 100644 --- a/sql/migrations.sql +++ b/sql/migrations.sql @@ -2515,3 +2515,15 @@ UPDATE scheduled_payins -- migration #117 ALTER TABLE notifications ADD COLUMN hidden_since timestamptz; + +-- migration #118 +ALTER TABLE email_blacklist ADD COLUMN ignored_by bigint REFERENCES participants; +UPDATE email_blacklist AS bl + SET ignore_after = current_timestamp + , ignored_by = e.participant + FROM emails e + WHERE lower(e.address) = lower(bl.address) + AND e.verified + AND (bl.ignore_after IS NULL OR bl.ignore_after > current_timestamp) + AND (bl.reason = 'bounce' AND bl.ts < (e.added_time + interval '24 hours') OR + bl.reason = 'complaint' AND bl.details = 'disavowed'); diff --git a/sql/schema.sql b/sql/schema.sql index 27eaa08695..4920a80512 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -14,7 +14,7 @@ COMMENT ON EXTENSION pg_stat_statements IS 'track execution statistics of all SQ -- database metadata CREATE TABLE db_meta (key text PRIMARY KEY, value jsonb); -INSERT INTO db_meta (key, value) VALUES ('schema_version', '117'::jsonb); +INSERT INTO db_meta (key, value) VALUES ('schema_version', '118'::jsonb); -- app configuration @@ -779,6 +779,7 @@ CREATE TABLE email_blacklist , ses_data jsonb , ignore_after timestamptz , report_id text +, ignored_by bigint REFERENCES participants ); CREATE INDEX email_blacklist_idx ON email_blacklist (lower(address));