Skip to content
Snippets Groups Projects
Commit 7336bd48 authored by Gabriel Mazetto's avatar Gabriel Mazetto
Browse files

Add site statistics recount to the post migiration

parent 1a54986c
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Loading
Loading
@@ -5,6 +5,8 @@ class MigrateNullWikiAccessLevels < ActiveRecord::Migration
 
DOWNTIME = false
 
disable_ddl_transaction!
class ProjectFeature < ActiveRecord::Base
include EachBatch
 
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment