Add site statistics recount to the post migiration
This commit is contained in:
parent
1a54986c16
commit
7336bd4843
1 changed files with 9 additions and 0 deletions
|
@ -5,6 +5,8 @@ class MigrateNullWikiAccessLevels < ActiveRecord::Migration
|
||||||
|
|
||||||
DOWNTIME = false
|
DOWNTIME = false
|
||||||
|
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
class ProjectFeature < ActiveRecord::Base
|
class ProjectFeature < ActiveRecord::Base
|
||||||
include EachBatch
|
include EachBatch
|
||||||
|
|
||||||
|
@ -15,6 +17,13 @@ class MigrateNullWikiAccessLevels < ActiveRecord::Migration
|
||||||
ProjectFeature.where(wiki_access_level: nil).each_batch do |relation|
|
ProjectFeature.where(wiki_access_level: nil).each_batch do |relation|
|
||||||
relation.update_all(wiki_access_level: 20)
|
relation.update_all(wiki_access_level: 20)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
|
Loading…
Reference in a new issue