diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2018-08-15 04:38:39 +0200 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2018-08-16 21:31:19 +0200 |
commit | 7336bd4843521956997c80a10705a83083eb122b (patch) | |
tree | 4933c7f4c482c1e1fb7c6a519f2c0271eb04ab81 /db | |
parent | 1a54986c166fb13a6a27afcafaa055e1a1749e38 (diff) | |
download | gitlab-ce-7336bd4843521956997c80a10705a83083eb122b.tar.gz |
Add site statistics recount to the post migirationrepopulate_site_statistics
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb b/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb index d3557efecbd..0a0a33299e4 100644 --- a/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb +++ b/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb @@ -5,6 +5,8 @@ class MigrateNullWikiAccessLevels < ActiveRecord::Migration DOWNTIME = false + disable_ddl_transaction! + class ProjectFeature < ActiveRecord::Base include EachBatch @@ -15,6 +17,13 @@ class MigrateNullWikiAccessLevels < ActiveRecord::Migration ProjectFeature.where(wiki_access_level: nil).each_batch do |relation| relation.update_all(wiki_access_level: 20) end + + # We need to re-count wikis as previous attempt was not considering the NULLs. + transaction do + execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967 + + execute("UPDATE site_statistics SET wikis_count = (SELECT COUNT(*) FROM project_features WHERE wiki_access_level != 0)") + end end def down |