From f301d547c2a3ca2a3f1fd07f9ddc4eb451e70244 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Thu, 4 Aug 2016 15:27:53 +0100 Subject: Add a data migration to fix some missing timestamps in the members table (again) --- ...20160804150737_add_timestamps_to_members_again.rb | 20 ++++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20160804150737_add_timestamps_to_members_again.rb diff --git a/db/migrate/20160804150737_add_timestamps_to_members_again.rb b/db/migrate/20160804150737_add_timestamps_to_members_again.rb new file mode 100644 index 00000000000..60f4e7af90f --- /dev/null +++ b/db/migrate/20160804150737_add_timestamps_to_members_again.rb @@ -0,0 +1,20 @@ +# rubocop:disable all +# 20141121133009_add_timestamps_to_members.rb was meant to ensure that all +# rows in the members table had created_at and updated_at set, following an +# error in a previous migration. This failed to set all rows in at least one +# case: https://gitlab.com/gitlab-org/gitlab-ce/issues/20568 +# +# Why this happened is lost in the mists of time, so repeat the SQL query +# without speculation, just in case more than one person was affected. +class AddTimestampsToMembersAgain < ActiveRecord::Migration + + def up + execute "UPDATE members SET created_at = NOW() WHERE created_at IS NULL" + execute "UPDATE members SET updated_at = NOW() WHERE updated_at IS NULL" + end + + def down + # no change + end + +end diff --git a/db/schema.rb b/db/schema.rb index dc28842758a..71980a6d51f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160802010328) do +ActiveRecord::Schema.define(version: 20160804150737) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.1