summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2018-11-30 17:03:29 +0100
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2018-12-06 21:04:41 -0200
commit5237a55d62f8dcb021a041741b3f09cad7784a36 (patch)
tree8c543fb224f2fe19a89f8a6758dd86dd9da53321 /db
parent0f338434b90b6e385c0c1947ff53c143dd7ed6be (diff)
downloadgitlab-ce-5237a55d62f8dcb021a041741b3f09cad7784a36.tar.gz
Fill project_repositories for hashed storage
This adds a background migration that will ensure all projects that are on hashed storage have a row in `project_repositories`. Related issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/48527
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20181130102132_backfill_hashed_project_repositories.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/db/post_migrate/20181130102132_backfill_hashed_project_repositories.rb b/db/post_migrate/20181130102132_backfill_hashed_project_repositories.rb
new file mode 100644
index 00000000000..b989d9fb43d
--- /dev/null
+++ b/db/post_migrate/20181130102132_backfill_hashed_project_repositories.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class BackfillHashedProjectRepositories < ActiveRecord::Migration[5.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ BATCH_SIZE = 1_000
+ DELAY_INTERVAL = 1.minutes
+ MIGRATION = 'BackfillHashedProjectRepositories'
+
+ disable_ddl_transaction!
+
+ class Project < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'projects'
+ end
+
+ def up
+ queue_background_migration_jobs_by_range_at_intervals(Project, MIGRATION, DELAY_INTERVAL)
+ end
+
+ def down
+ # Since there could have been existing rows before the migration
+ # do not remove anything
+ end
+end