summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-08-04 20:03:14 +0000
committerDouwe Maan <douwe@gitlab.com>2016-08-04 20:03:14 +0000
commit1aba0668ee0c98b5274517692c73958801cdb285 (patch)
tree9308b0710cfd167f8366e584b254725e67d2cc5b
parent6df51b35d598a3ec553100323c0f0611e1e3d1e1 (diff)
parent98260f36cf697665509b89288c4208007d8ad6ce (diff)
downloadgitlab-ce-1aba0668ee0c98b5274517692c73958801cdb285.tar.gz
Merge branch '20568-fix-member-data-again' into 'master'
Add a data migration to fix some missing timestamps in the members table (again) ## What does this MR do? Repeats an earlier migration to fix historic bad data in the members table (missing created_at and updated_at fields) ## Are there points in the code the reviewer needs to double check? I'm expecting the WHERE clauses to be fast enough, and to return few enough rows, that the migration doesn't need to use batches, but I'm not too familiar with the size of these tables in the wild, so perhaps that's a poor assumption. ## Why was this MR needed? 8.10 introduced a dependency on the `members.created_at` field in the project and namespace member view. If bad data is present, viewing the list of members now results in an NoMethodError and a 500 response from GitLab. Although the previous migration should have fixed all bad rows, we have evidence that it didn't in at least one case, despite the migration claiming to have run in the past. ## What are the relevant issue numbers? #20568 ## Screenshots (if relevant) ## Does this MR meet the acceptance criteria? - [ ] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [ ] API support added - Tests - [ ] Added for this feature/bug - [ ] All builds are passing - [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [ ] Branch has no merge conflicts with `master` (if you do - rebase it please) - [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) Closes #20568 See merge request !5670
-rw-r--r--db/migrate/20160804150737_add_timestamps_to_members_again.rb21
-rw-r--r--db/schema.rb2
2 files changed, 22 insertions, 1 deletions
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..6691ba57fbb
--- /dev/null
+++ b/db/migrate/20160804150737_add_timestamps_to_members_again.rb
@@ -0,0 +1,21 @@
+# 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
+ DOWNTIME = false
+
+ 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"