From 76665f725bc90c5122b4f9f5cf80b75fedbdf885 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 4 Sep 2015 15:11:25 -0700 Subject: [PATCH] Correct a bad Herald migration Summary: One of the migrations in rPa335004a91 (`20150730.herald.5.sql`) incorrectly swapped "add" and "add blocking" Differential Herald rules. Swap any rules last modified before this patch was applied back. This is the best we can do without possibly overwriting more recent, intentional data. I'll issue some guidance on this in the changelog. Test Plan: - Made a rule, ran patch, no change. - Changed rule modified time to a few months ago, ran patch, saw swap from non-blocking to blocking. Reviewers: chad Reviewed By: chad Differential Revision: https://secure.phabricator.com/D14061 --- .../sql/autopatches/20150904.herald.1.sql | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 resources/sql/autopatches/20150904.herald.1.sql diff --git a/resources/sql/autopatches/20150904.herald.1.sql b/resources/sql/autopatches/20150904.herald.1.sql new file mode 100644 index 0000000000..17f945cc30 --- /dev/null +++ b/resources/sql/autopatches/20150904.herald.1.sql @@ -0,0 +1,52 @@ +/* The "20150730.herald.5.sql" patch incorrectly swapped blocking and + non-blocking "Add Reviewer" rules. This swaps back any rules which + were last modified before the patch was applied. */ + +UPDATE {$NAMESPACE}_herald.herald_action a + JOIN {$NAMESPACE}_herald.herald_rule r + ON a.ruleID = r.id + SET a.action = 'differential.reviewers.blocking.tmp' + WHERE a.action = 'differential.reviewers.add' + AND r.dateModified <= + (SELECT applied FROM {$NAMESPACE}_meta_data.patch_status + WHERE patch = 'phabricator:20150730.herald.5.sql'); + +UPDATE {$NAMESPACE}_herald.herald_action a + JOIN {$NAMESPACE}_herald.herald_rule r + ON a.ruleID = r.id + SET a.action = 'differential.reviewers.add' + WHERE a.action = 'differential.reviewers.blocking' + AND r.dateModified <= + (SELECT applied FROM {$NAMESPACE}_meta_data.patch_status + WHERE patch = 'phabricator:20150730.herald.5.sql'); + +UPDATE {$NAMESPACE}_herald.herald_action a + JOIN {$NAMESPACE}_herald.herald_rule r + ON a.ruleID = r.id + SET a.action = 'differential.reviewers.blocking' + WHERE a.action = 'differential.reviewers.blocking.tmp'; + + +UPDATE {$NAMESPACE}_herald.herald_action a + JOIN {$NAMESPACE}_herald.herald_rule r + ON a.ruleID = r.id + SET a.action = 'differential.reviewers.self.blocking.tmp' + WHERE a.action = 'differential.reviewers.self.add' + AND r.dateModified <= + (SELECT applied FROM {$NAMESPACE}_meta_data.patch_status + WHERE patch = 'phabricator:20150730.herald.5.sql'); + +UPDATE {$NAMESPACE}_herald.herald_action a + JOIN {$NAMESPACE}_herald.herald_rule r + ON a.ruleID = r.id + SET a.action = 'differential.reviewers.self.add' + WHERE a.action = 'differential.reviewers.self.blocking' + AND r.dateModified <= + (SELECT applied FROM {$NAMESPACE}_meta_data.patch_status + WHERE patch = 'phabricator:20150730.herald.5.sql'); + +UPDATE {$NAMESPACE}_herald.herald_action a + JOIN {$NAMESPACE}_herald.herald_rule r + ON a.ruleID = r.id + SET a.action = 'differential.reviewers.self.blocking' + WHERE a.action = 'differential.reviewers.self.blocking.tmp';