diff options
author | Rubén Dávila <ruben@gitlab.com> | 2018-12-07 16:29:53 +0300 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2018-12-07 16:29:53 +0300 |
commit | b2cf4b9525f41b2de7c96c493d0fe296760a736b (patch) | |
tree | 5424623f4e6092ed8a610adef45a59a4003271b6 /lib/gitlab/database | |
parent | a2e06ad3034cd1e007b78514a5c1f47feef7b648 (diff) |
Backports some changes from gitlab-ee!7885
Diffstat (limited to 'lib/gitlab/database')
-rw-r--r-- | lib/gitlab/database/migration_helpers.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index 134d1e7a724..d9578852db6 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -975,9 +975,10 @@ into similar problems in the future (e.g. when new tables are created). raise "#{model_class} does not have an ID to use for batch ranges" unless model_class.column_names.include?('id') jobs = [] + table_name = model_class.quoted_table_name model_class.each_batch(of: batch_size) do |relation| - start_id, end_id = relation.pluck('MIN(id), MAX(id)').first + start_id, end_id = relation.pluck("MIN(#{table_name}.id), MAX(#{table_name}.id)").first if jobs.length >= BACKGROUND_MIGRATION_JOB_BUFFER_SIZE # Note: This code path generally only helps with many millions of rows |