summaryrefslogtreecommitdiff
path: root/lib/gitlab/background_migration/backfill_project_settings.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/background_migration/backfill_project_settings.rb')
-rw-r--r--lib/gitlab/background_migration/backfill_project_settings.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/backfill_project_settings.rb b/lib/gitlab/background_migration/backfill_project_settings.rb
new file mode 100644
index 00000000000..7d7f19e1fda
--- /dev/null
+++ b/lib/gitlab/background_migration/backfill_project_settings.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module BackgroundMigration
+ # Backfill project_settings for a range of projects
+ class BackfillProjectSettings
+ def perform(start_id, end_id)
+ ActiveRecord::Base.connection.execute <<~SQL
+ INSERT INTO project_settings (project_id, created_at, updated_at)
+ SELECT projects.id, now(), now()
+ FROM projects
+ WHERE projects.id BETWEEN #{start_id} AND #{end_id}
+ ON CONFLICT (project_id) DO NOTHING;
+ SQL
+ end
+ end
+ end
+end