From 956e3ad2088a9ebe09338b94689f91d5975753e9 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 8 Jan 2016 16:52:29 +1100 Subject: [PATCH] FIX: correct user_history that was off by one --- ...160108051129_fix_incorrect_user_history.rb | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 db/migrate/20160108051129_fix_incorrect_user_history.rb diff --git a/db/migrate/20160108051129_fix_incorrect_user_history.rb b/db/migrate/20160108051129_fix_incorrect_user_history.rb new file mode 100644 index 00000000000..2a9cbdf0fbc --- /dev/null +++ b/db/migrate/20160108051129_fix_incorrect_user_history.rb @@ -0,0 +1,34 @@ +class FixIncorrectUserHistory < ActiveRecord::Migration + def up + # see https://meta.discourse.org/t/old-user-suspension-reasons-have-gone-missing/3730 + # we had a window of 21 days where all user history records with action > 5 were off by one + # + # to correct we are doing this https://meta.discourse.org/t/enums-that-are-used-in-tables-need-to-be-stable/37622 + # + # This migration hunts for date stuff started going wrong and date it started being good and corrects the data + + + # this is a :auto_trust_level_change mislabled as :check_email + # impersonate that was actually delete topic + condition = < 5 AND id >= #{first_wrong_id} AND id <= #{last_wrong_id}") + + execute("INSERT INTO user_histories(action, acting_user_id, details, created_at, updated_at) + VALUES (22, -1, '#{msg}', current_timestamp, current_timestamp)") + end + end + + def down + end +end