diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /db/post_migrate/20201104124300_ensure_namespace_settings_creation.rb | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'db/post_migrate/20201104124300_ensure_namespace_settings_creation.rb')
-rw-r--r-- | db/post_migrate/20201104124300_ensure_namespace_settings_creation.rb | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/db/post_migrate/20201104124300_ensure_namespace_settings_creation.rb b/db/post_migrate/20201104124300_ensure_namespace_settings_creation.rb deleted file mode 100644 index 08f92d21f44..00000000000 --- a/db/post_migrate/20201104124300_ensure_namespace_settings_creation.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -class EnsureNamespaceSettingsCreation < ActiveRecord::Migration[5.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - BATCH_SIZE = 10000 - MIGRATION = 'BackfillNamespaceSettings' - DELAY_INTERVAL = 2.minutes.to_i - - disable_ddl_transaction! - - class Namespace < ActiveRecord::Base - include EachBatch - - self.table_name = 'namespaces' - end - - def up - ensure_data_migration - end - - def down - # no-op - end - - private - - def ensure_data_migration - Namespace.each_batch(of: BATCH_SIZE) do |query, index| - missing_count = query.where("NOT EXISTS (SELECT 1 FROM namespace_settings WHERE namespace_settings.namespace_id=namespaces.id)").limit(1).size - - if missing_count > 0 - ids_range = query.pluck("MIN(id), MAX(id)").flatten - - migrate_in(index * DELAY_INTERVAL, MIGRATION, ids_range) - end - end - end -end |