diff options
Diffstat (limited to 'db')
425 files changed, 1660 insertions, 1648 deletions
diff --git a/db/fixtures/development/01_admin.rb b/db/fixtures/development/01_admin.rb index 1e260236dc5..89c3623bee0 100644 --- a/db/fixtures/development/01_admin.rb +++ b/db/fixtures/development/01_admin.rb @@ -1,14 +1,14 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" Gitlab::Seeder.quiet do User.create!( - name: 'Administrator', - email: 'admin@example.com', - username: 'root', - password: '5iveL!fe', + name: "Administrator", + email: "admin@example.com", + username: "root", + password: "5iveL!fe", admin: true, confirmed_at: DateTime.now ) - print '.' + print "." end diff --git a/db/fixtures/development/03_settings.rb b/db/fixtures/development/03_settings.rb index 3a4a5d436bf..4c0fa0573bd 100644 --- a/db/fixtures/development/03_settings.rb +++ b/db/fixtures/development/03_settings.rb @@ -4,5 +4,5 @@ Gitlab::Seeder.quiet do ApplicationSetting.create_from_defaults unless ApplicationSetting.current_without_cache ApplicationSetting.current_without_cache.update!(hashed_storage_enabled: true) - print '.' + print "." end diff --git a/db/fixtures/development/04_project.rb b/db/fixtures/development/04_project.rb index 9a5f7cf8175..3efcc7881be 100644 --- a/db/fixtures/development/04_project.rb +++ b/db/fixtures/development/04_project.rb @@ -1,4 +1,4 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" # rubocop:disable Rails/Output @@ -50,7 +50,7 @@ Sidekiq::Testing.inline! do ] def create_project(url, force_latest_storage: false) - group_path, project_path = url.split('/')[-2..-1] + group_path, project_path = url.split("/")[-2..-1] group = Group.find_by(path: group_path) @@ -73,7 +73,7 @@ Sidekiq::Testing.inline! do name: project_path.titleize, description: FFaker::Lorem.sentence, visibility_level: Gitlab::VisibilityLevel.values.sample, - skip_disk_validation: true + skip_disk_validation: true, } if force_latest_storage @@ -94,27 +94,27 @@ Sidekiq::Testing.inline! do end if project.valid? && project.valid_repo? - print '.' + print "." else puts project.errors.full_messages - print 'F' + print "F" end end # You can specify how many projects you need during seed execution - size = ENV['SIZE'].present? ? ENV['SIZE'].to_i : 8 + size = ENV["SIZE"].present? ? ENV["SIZE"].to_i : 8 project_urls.first(size).each_with_index do |url, i| create_project(url, force_latest_storage: i.even?) end - if ENV['LARGE_PROJECTS'].present? + if ENV["LARGE_PROJECTS"].present? large_project_urls.each(&method(:create_project)) - if ENV['FORK'].present? + if ENV["FORK"].present? puts "\nGenerating forks" - project_name = ENV['FORK'] == 'true' ? 'torvalds/linux' : ENV['FORK'] + project_name = ENV["FORK"] == "true" ? "torvalds/linux" : ENV["FORK"] project = Project.find_by_full_path(project_name) @@ -122,12 +122,12 @@ Sidekiq::Testing.inline! do new_project = Projects::ForkService.new(project, user).execute if new_project.valid? && (new_project.valid_repo? || new_project.import_state.scheduled?) - print '.' + print "." else new_project.errors.full_messages.each do |error| puts "#{new_project.full_path}: #{error}" end - print 'F' + print "F" end end end diff --git a/db/fixtures/development/05_users.rb b/db/fixtures/development/05_users.rb index 101ff3a1209..b1623f3e3da 100644 --- a/db/fixtures/development/05_users.rb +++ b/db/fixtures/development/05_users.rb @@ -1,34 +1,30 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" Gitlab::Seeder.quiet do 20.times do |i| - begin - User.create!( - username: FFaker::Internet.user_name, - name: FFaker::Name.name, - email: FFaker::Internet.email, - confirmed_at: DateTime.now, - password: '12345678' - ) + User.create!( + username: FFaker::Internet.user_name, + name: FFaker::Name.name, + email: FFaker::Internet.email, + confirmed_at: DateTime.now, + password: "12345678" + ) - print '.' - rescue ActiveRecord::RecordInvalid - print 'F' - end + print "." + rescue ActiveRecord::RecordInvalid + print "F" end 5.times do |i| - begin - User.create!( - username: "user#{i}", - name: "User #{i}", - email: "user#{i}@example.com", - confirmed_at: DateTime.now, - password: '12345678' - ) - print '.' - rescue ActiveRecord::RecordInvalid - print 'F' - end + User.create!( + username: "user#{i}", + name: "User #{i}", + email: "user#{i}@example.com", + confirmed_at: DateTime.now, + password: "12345678" + ) + print "." + rescue ActiveRecord::RecordInvalid + print "F" end end diff --git a/db/fixtures/development/06_teams.rb b/db/fixtures/development/06_teams.rb index b218f4e71fd..e1867918dff 100644 --- a/db/fixtures/development/06_teams.rb +++ b/db/fixtures/development/06_teams.rb @@ -1,13 +1,13 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" Sidekiq::Testing.inline! do Gitlab::Seeder.quiet do Group.all.each do |group| User.all.sample(4).each do |user| if group.add_user(user, Gitlab::Access.values.sample).persisted? - print '.' + print "." else - print 'F' + print "F" end end end @@ -15,9 +15,9 @@ Sidekiq::Testing.inline! do Project.all.each do |project| User.all.sample(4).each do |user| if project.add_role(user, Gitlab::Access.sym_options.keys.sample) - print '.' + print "." else - print 'F' + print "F" end end end diff --git a/db/fixtures/development/07_milestones.rb b/db/fixtures/development/07_milestones.rb index 271bfbc97e0..cc5385843fe 100644 --- a/db/fixtures/development/07_milestones.rb +++ b/db/fixtures/development/07_milestones.rb @@ -1,4 +1,4 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" Gitlab::Seeder.quiet do Project.all.each do |project| @@ -10,9 +10,10 @@ Gitlab::Seeder.quiet do } milestone = Milestones::CreateService.new( - project, project.team.users.sample, milestone_params).execute + project, project.team.users.sample, milestone_params + ).execute - print '.' + print "." end end end diff --git a/db/fixtures/development/08_settings.rb b/db/fixtures/development/08_settings.rb index 141465c06cf..5cd0df7da5c 100644 --- a/db/fixtures/development/08_settings.rb +++ b/db/fixtures/development/08_settings.rb @@ -3,5 +3,5 @@ Gitlab::Seeder.quiet do ApplicationSetting.create_from_defaults unless ApplicationSetting.current_without_cache ApplicationSetting.current_without_cache.update!(hashed_storage_enabled: true) - print '.' + print "." end diff --git a/db/fixtures/development/09_issues.rb b/db/fixtures/development/09_issues.rb index 16243b72f9a..13bac578c67 100644 --- a/db/fixtures/development/09_issues.rb +++ b/db/fixtures/development/09_issues.rb @@ -1,4 +1,4 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" Gitlab::Seeder.quiet do Project.all.each do |project| @@ -6,14 +6,14 @@ Gitlab::Seeder.quiet do issue_params = { title: FFaker::Lorem.sentence(6), description: FFaker::Lorem.sentence, - state: ['opened', 'closed'].sample, + state: ["opened", "closed"].sample, milestone: project.milestones.sample, assignees: [project.team.users.sample], - created_at: rand(12).months.ago + created_at: rand(12).months.ago, } Issues::CreateService.new(project, project.team.users.sample, issue_params).execute - print '.' + print "." end end end diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb index 2051bcff8f0..9411e8a7670 100644 --- a/db/fixtures/development/10_merge_requests.rb +++ b/db/fixtures/development/10_merge_requests.rb @@ -1,4 +1,4 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" Gitlab::Seeder.quiet do # Limit the number of merge requests per project to avoid long seeds @@ -18,7 +18,7 @@ Gitlab::Seeder.quiet do title: FFaker::Lorem.sentence(6), description: FFaker::Lorem.sentences(3).join(" "), milestone: project.milestones.sample, - assignee: project.team.users.sample + assignee: project.team.users.sample, } # Only create MRs with users that are allowed to create MRs @@ -31,31 +31,31 @@ Gitlab::Seeder.quiet do # Ignore pipelines creation errors for now, we can doing that after # https://gitlab.com/gitlab-org/gitlab-ce/issues/55966. will be resolved. end - print '.' + print "." end end - project = Project.find_by_full_path('gitlab-org/gitlab-test') + project = Project.find_by_full_path("gitlab-org/gitlab-test") next if project.empty_repo? # We don't have repository on CI params = { - source_branch: 'feature', - target_branch: 'master', - title: 'Can be automatically merged' + source_branch: "feature", + target_branch: "master", + title: "Can be automatically merged", } Sidekiq::Worker.skipping_transaction_check do MergeRequests::CreateService.new(project, User.admins.first, params).execute end - print '.' + print "." params = { - source_branch: 'feature_conflict', - target_branch: 'feature', - title: 'Cannot be automatically merged' + source_branch: "feature_conflict", + target_branch: "feature", + title: "Cannot be automatically merged", } Sidekiq::Worker.skipping_transaction_check do MergeRequests::CreateService.new(project, User.admins.first, params).execute end - print '.' + print "." end diff --git a/db/fixtures/development/11_keys.rb b/db/fixtures/development/11_keys.rb index c405ecfdaf3..2a984147793 100644 --- a/db/fixtures/development/11_keys.rb +++ b/db/fixtures/development/11_keys.rb @@ -1,5 +1,4 @@ -require './spec/support/sidekiq' - +require "./spec/support/sidekiq" # Creating keys runs a gitlab-shell worker. Since we may not have the right # gitlab-shell path set (yet) we need to disable this for these fixtures. @@ -21,7 +20,7 @@ Sidekiq::Testing.disable! do key.add_to_shell end - print '.' + print "." end end end diff --git a/db/fixtures/development/12_snippets.rb b/db/fixtures/development/12_snippets.rb index a9f4069a0f8..861024c4632 100644 --- a/db/fixtures/development/12_snippets.rb +++ b/db/fixtures/development/12_snippets.rb @@ -1,28 +1,28 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" Gitlab::Seeder.quiet do - content =<<eos -class Member < ActiveRecord::Base - include Notifiable - include Gitlab::Access - - belongs_to :user - belongs_to :source, polymorphic: true - - validates :user, presence: true - validates :source, presence: true - validates :user_id, uniqueness: { scope: [:source_type, :source_id], message: "already exists in source" } - validates :access_level, inclusion: { in: Gitlab::Access.all_values }, presence: true - - scope :guests, -> { where(access_level: GUEST) } - scope :reporters, -> { where(access_level: REPORTER) } - scope :developers, -> { where(access_level: DEVELOPER) } - scope :maintainers, -> { where(access_level: MAINTAINER) } - scope :owners, -> { where(access_level: OWNER) } - - delegate :name, :username, :email, to: :user, prefix: true -end -eos + content = <<~eos + class Member < ActiveRecord::Base + include Notifiable + include Gitlab::Access + + belongs_to :user + belongs_to :source, polymorphic: true + + validates :user, presence: true + validates :source, presence: true + validates :user_id, uniqueness: { scope: [:source_type, :source_id], message: "already exists in source" } + validates :access_level, inclusion: { in: Gitlab::Access.all_values }, presence: true + + scope :guests, -> { where(access_level: GUEST) } + scope :reporters, -> { where(access_level: REPORTER) } + scope :developers, -> { where(access_level: DEVELOPER) } + scope :maintainers, -> { where(access_level: MAINTAINER) } + scope :owners, -> { where(access_level: OWNER) } + + delegate :name, :username, :email, to: :user, prefix: true + end + eos 50.times do |i| user = User.all.sample @@ -31,12 +31,11 @@ eos id: i, author_id: user.id, title: FFaker::Lorem.sentence(3), - file_name: FFaker::Internet.domain_word + '.rb', + file_name: FFaker::Internet.domain_word + ".rb", visibility_level: Gitlab::VisibilityLevel.values.sample, content: content, }]) - print('.') + print(".") end end - diff --git a/db/fixtures/development/13_comments.rb b/db/fixtures/development/13_comments.rb index bc2d74c8034..cd698ff87ed 100644 --- a/db/fixtures/development/13_comments.rb +++ b/db/fixtures/development/13_comments.rb @@ -1,4 +1,4 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" Gitlab::Seeder.quiet do Issue.find_each do |issue| @@ -6,13 +6,13 @@ Gitlab::Seeder.quiet do project.team.users.each do |user| note_params = { - noteable_type: 'Issue', + noteable_type: "Issue", noteable_id: issue.id, note: FFaker::Lorem.sentence, } Notes::CreateService.new(project, user, note_params).execute - print '.' + print "." end end @@ -21,13 +21,13 @@ Gitlab::Seeder.quiet do project.team.users.each do |user| note_params = { - noteable_type: 'MergeRequest', + noteable_type: "MergeRequest", noteable_id: mr.id, note: FFaker::Lorem.sentence, } Notes::CreateService.new(project, user, note_params).execute - print '.' + print "." end end end diff --git a/db/fixtures/development/14_pipelines.rb b/db/fixtures/development/14_pipelines.rb index db043e39d2c..9a380af8f85 100644 --- a/db/fixtures/development/14_pipelines.rb +++ b/db/fixtures/development/14_pipelines.rb @@ -1,61 +1,61 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" class Gitlab::Seeder::Pipelines STAGES = %w[build test security deploy notify] BUILDS = [ # build stage - { name: 'build:linux', stage: 'build', status: :success, - queued_at: 10.hour.ago, started_at: 9.hour.ago, finished_at: 8.hour.ago }, - { name: 'build:osx', stage: 'build', status: :success, - queued_at: 10.hour.ago, started_at: 10.hour.ago, finished_at: 9.hour.ago }, + {name: "build:linux", stage: "build", status: :success, + queued_at: 10.hour.ago, started_at: 9.hour.ago, finished_at: 8.hour.ago,}, + {name: "build:osx", stage: "build", status: :success, + queued_at: 10.hour.ago, started_at: 10.hour.ago, finished_at: 9.hour.ago,}, # test stage - { name: 'rspec:linux 0 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:linux 1 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:linux 2 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:windows 0 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:windows 1 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:windows 2 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:windows 2 3', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'rspec:osx', stage: 'test', status_event: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'spinach:linux', stage: 'test', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'spinach:osx', stage: 'test', status: :failed, allow_failure: true, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, + {name: "rspec:linux 0 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:linux 1 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:linux 2 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:windows 0 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:windows 1 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:windows 2 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:windows 2 3", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "rspec:osx", stage: "test", status_event: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "spinach:linux", stage: "test", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "spinach:osx", stage: "test", status: :failed, allow_failure: true, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, # security stage - { name: 'dast', stage: 'security', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'sast', stage: 'security', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'dependency_scanning', stage: 'security', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'container_scanning', stage: 'security', status: :success, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, + {name: "dast", stage: "security", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "sast", stage: "security", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "dependency_scanning", stage: "security", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, + {name: "container_scanning", stage: "security", status: :success, + queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,}, # deploy stage - { name: 'staging', stage: 'deploy', environment: 'staging', status_event: :success, - options: { environment: { action: 'start', on_stop: 'stop staging' } }, - queued_at: 7.hour.ago, started_at: 6.hour.ago, finished_at: 4.hour.ago }, - { name: 'stop staging', stage: 'deploy', environment: 'staging', - when: 'manual', status: :skipped }, - { name: 'production', stage: 'deploy', environment: 'production', - when: 'manual', status: :skipped }, + {name: "staging", stage: "deploy", environment: "staging", status_event: :success, + options: {environment: {action: "start", on_stop: "stop staging"}}, + queued_at: 7.hour.ago, started_at: 6.hour.ago, finished_at: 4.hour.ago,}, + {name: "stop staging", stage: "deploy", environment: "staging", + when: "manual", status: :skipped,}, + {name: "production", stage: "deploy", environment: "production", + when: "manual", status: :skipped,}, # notify stage - { name: 'slack', stage: 'notify', when: 'manual', status: :success }, + {name: "slack", stage: "notify", when: "manual", status: :success}, ] EXTERNAL_JOBS = [ - { name: 'jenkins', stage: 'test', status: :success, - queued_at: 7.hour.ago, started_at: 6.hour.ago, finished_at: 4.hour.ago }, + {name: "jenkins", stage: "test", status: :success, + queued_at: 7.hour.ago, started_at: 6.hour.ago, finished_at: 4.hour.ago,}, ] def initialize(project) @@ -78,15 +78,15 @@ class Gitlab::Seeder::Pipelines end def create_master_pipelines - @project.repository.commits('master', limit: 4).map do |commit| - create_pipeline!(@project, 'master', commit) + @project.repository.commits("master", limit: 4).map do |commit| + create_pipeline!(@project, "master", commit) end rescue [] end def create_merge_request_pipelines - pipelines = @project.merge_requests.first(3).map do |merge_request| + pipelines = @project.merge_requests.first(3).map { |merge_request| project = merge_request.source_project branch = merge_request.source_branch @@ -95,7 +95,7 @@ class Gitlab::Seeder::Pipelines merge_request.update!(head_pipeline_id: pipeline.id) end end - end + } pipelines.flatten rescue @@ -110,7 +110,7 @@ class Gitlab::Seeder::Pipelines attributes = job_attributes(pipeline, opts) attributes[:options] ||= {} - attributes[:options][:script] = 'build command' + attributes[:options][:script] = "build command" Ci::Build.create!(attributes).tap do |build| # We need to set build trace and artifacts after saving a build @@ -126,8 +126,8 @@ class Gitlab::Seeder::Pipelines end setup_build_log(build) - build.project.environments. - find_or_create_by(name: build.expanded_environment_name) + build.project.environments + .find_or_create_by(name: build.expanded_environment_name) build.save! end @@ -164,14 +164,15 @@ class Gitlab::Seeder::Pipelines # we have two sources: master and feature-branch branch_name = build.ref == build.project.default_branch ? - 'master' : 'feature-branch' + "master" : "feature-branch" artifacts_cache_file(security_reports_path(branch_name, build.name)) do |file| build.job_artifacts.build( project: build.project, file_type: build.name, file_format: :raw, - file: file) + file: file +) end end @@ -180,14 +181,15 @@ class Gitlab::Seeder::Pipelines # we have two sources: master and feature-branch branch_name = build.ref == build.project.default_branch ? - 'master' : 'feature-branch' + "master" : "feature-branch" artifacts_cache_file(security_reports_archive_path(branch_name)) do |file| build.job_artifacts.build( project: build.project, file_type: :archive, file_format: :zip, - file: file) + file: file +) end # assign dummy metadata @@ -196,20 +198,21 @@ class Gitlab::Seeder::Pipelines project: build.project, file_type: :metadata, file_format: :gzip, - file: file) + file: file +) end build.options = { artifacts: { paths: [ - Ci::JobArtifact::DEFAULT_FILE_NAMES.fetch(build.name.to_sym) - ] - } + Ci::JobArtifact::DEFAULT_FILE_NAMES.fetch(build.name.to_sym), + ], + }, } end def setup_build_log(build) - if %w(running success failed).include?(build.status) + if %w[running success failed].include?(build.status) build.trace.set(FFaker::Lorem.paragraphs(6).join("\n\n")) end end @@ -221,10 +224,9 @@ class Gitlab::Seeder::Pipelines end def job_attributes(pipeline, opts) - { name: 'test build', stage: 'test', stage_idx: stage_index(opts[:stage]), + {name: "test build", stage: "test", stage_idx: stage_index(opts[:stage]), ref: pipeline.ref, tag: false, user: build_user, project: @project, pipeline: pipeline, - created_at: Time.now, updated_at: Time.now - }.merge(opts) + created_at: Time.now, updated_at: Time.now},.merge(opts) end def build_user @@ -240,28 +242,28 @@ class Gitlab::Seeder::Pipelines end def artifacts_archive_path - Rails.root + 'spec/fixtures/ci_build_artifacts.zip' + Rails.root + "spec/fixtures/ci_build_artifacts.zip" end def artifacts_metadata_path - Rails.root + 'spec/fixtures/ci_build_artifacts_metadata.gz' + Rails.root + "spec/fixtures/ci_build_artifacts_metadata.gz" end def test_reports_pass_path - Rails.root + 'spec/fixtures/junit/junit_ant.xml.gz' + Rails.root + "spec/fixtures/junit/junit_ant.xml.gz" end def test_reports_failed_path - Rails.root + 'spec/fixtures/junit/junit.xml.gz' + Rails.root + "spec/fixtures/junit/junit.xml.gz" end def security_reports_archive_path(branch) - Rails.root.join('spec', 'fixtures', 'security-reports', branch + '.zip') + Rails.root.join("spec", "fixtures", "security-reports", branch + ".zip") end def security_reports_path(branch, name) file_name = Ci::JobArtifact::DEFAULT_FILE_NAMES.fetch(name.to_sym) - Rails.root.join('spec', 'fixtures', 'security-reports', branch, file_name) + Rails.root.join("spec", "fixtures", "security-reports", branch, file_name) end def artifacts_cache_file(file_path) diff --git a/db/fixtures/development/15_award_emoji.rb b/db/fixtures/development/15_award_emoji.rb index 137a036edaf..a9257979c7d 100644 --- a/db/fixtures/development/15_award_emoji.rb +++ b/db/fixtures/development/15_award_emoji.rb @@ -1,4 +1,4 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" Gitlab::Seeder.quiet do emoji = Gitlab::Emoji.emojis.keys @@ -14,7 +14,7 @@ Gitlab::Seeder.quiet do note.create_award_emoji(emoji.sample, user) end - print '.' + print "." end end @@ -29,7 +29,7 @@ Gitlab::Seeder.quiet do note.create_award_emoji(emoji.sample, user) end - print '.' + print "." end end end diff --git a/db/fixtures/development/16_protected_branches.rb b/db/fixtures/development/16_protected_branches.rb index 39d466fb43f..2bf25d12ded 100644 --- a/db/fixtures/development/16_protected_branches.rb +++ b/db/fixtures/development/16_protected_branches.rb @@ -1,14 +1,14 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" Gitlab::Seeder.quiet do admin_user = User.find(1) Project.all.each do |project| params = { - name: 'master' + name: "master", } ProtectedBranches::CreateService.new(project, admin_user, params).execute - print '.' + print "." end end diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb index 7a86fe2eb7c..b874cc60963 100644 --- a/db/fixtures/development/17_cycle_analytics.rb +++ b/db/fixtures/development/17_cycle_analytics.rb @@ -1,5 +1,5 @@ -require './spec/support/sidekiq' -require './spec/support/helpers/test_env' +require "./spec/support/sidekiq" +require "./spec/support/helpers/test_env" class Gitlab::Seeder::CycleAnalytics def initialize(project, perf: false) @@ -31,8 +31,8 @@ class Gitlab::Seeder::CycleAnalytics # MR Timecop.travel 5.days.from_now branch_name = "#{FFaker::Product.brand}-#{FFaker::Product.brand}-#{rand(1000)}" - @project.repository.add_branch(@user, branch_name, 'master') - merge_request = MergeRequest.create(target_project: @project, source_project: @project, source_branch: branch_name, target_branch: 'master', title: branch_name, author: @user) + @project.repository.add_branch(@user, branch_name, "master") + merge_request = MergeRequest.create(target_project: @project, source_project: @project, source_branch: branch_name, target_branch: "master", title: branch_name, author: @user) merge_request_metrics = merge_request.metrics # MR closing issues @@ -58,7 +58,7 @@ class Gitlab::Seeder::CycleAnalytics issue_metrics.save! merge_request_metrics.save! - print '.' + print "." end end @@ -66,41 +66,41 @@ class Gitlab::Seeder::CycleAnalytics Sidekiq::Worker.skipping_transaction_check do Sidekiq::Testing.inline! do issues = create_issues - puts '.' + puts "." # Stage 1 Timecop.travel 5.days.from_now add_milestones_and_list_labels(issues) - print '.' + print "." # Stage 2 Timecop.travel 5.days.from_now branches = mention_in_commits(issues) - print '.' + print "." # Stage 3 Timecop.travel 5.days.from_now merge_requests = create_merge_requests_closing_issues(issues, branches) - print '.' + print "." # Stage 4 Timecop.travel 5.days.from_now run_builds(merge_requests) - print '.' + print "." # Stage 5 Timecop.travel 5.days.from_now merge_merge_requests(merge_requests) - print '.' + print "." # Stage 6 / 7 Timecop.travel 5.days.from_now deploy_to_production(merge_requests) - print '.' + print "." end end - print '.' + print "." end private @@ -110,8 +110,8 @@ class Gitlab::Seeder::CycleAnalytics issue_params = { title: "Cycle Analytics: #{FFaker::Lorem.sentence(6)}", description: FFaker::Lorem.sentence, - state: 'opened', - assignees: [@project.team.users.sample] + state: "opened", + assignees: [@project.team.users.sample], } Issues::CreateService.new(@project, @project.team.users.sample, issue_params).execute @@ -141,16 +141,16 @@ class Gitlab::Seeder::CycleAnalytics branch_name = filename = "#{FFaker::Product.brand}-#{FFaker::Product.brand}-#{rand(1000)}" - issue.project.repository.add_branch(@user, branch_name, 'master') + issue.project.repository.add_branch(@user, branch_name, "master") commit_sha = issue.project.repository.create_file(@user, filename, "content", message: "Commit for #{issue.to_reference}", branch_name: branch_name) issue.project.repository.commit(commit_sha) GitPushService.new(issue.project, - @user, - oldrev: issue.project.repository.commit("master").sha, - newrev: commit_sha, - ref: 'refs/heads/master').execute + @user, + oldrev: issue.project.repository.commit("master").sha, + newrev: commit_sha, + ref: "refs/heads/master").execute branch_name end @@ -161,10 +161,10 @@ class Gitlab::Seeder::CycleAnalytics Timecop.travel 12.hours.from_now opts = { - title: 'Cycle Analytics merge_request', + title: "Cycle Analytics merge_request", description: "Fixes #{issue.to_reference}", source_branch: branch, - target_branch: 'master' + target_branch: "master", } MergeRequests::CreateService.new(issue.project, @user, opts).execute @@ -176,8 +176,8 @@ class Gitlab::Seeder::CycleAnalytics Timecop.travel 12.hours.from_now service = Ci::CreatePipelineService.new(merge_request.project, - @user, - ref: "refs/heads/#{merge_request.source_branch}") + @user, + ref: "refs/heads/#{merge_request.source_branch}") pipeline = service.execute(:push, ignore_skip_ci: true, save_on_errors: false) pipeline.builds.map(&:run!) @@ -208,7 +208,7 @@ class Gitlab::Seeder::CycleAnalytics end Gitlab::Seeder.quiet do - flag = 'SEED_CYCLE_ANALYTICS' + flag = "SEED_CYCLE_ANALYTICS" if ENV[flag] Project.find_each do |project| @@ -217,15 +217,15 @@ Gitlab::Seeder.quiet do # GDK seed, but is almost never true for a GDK that's actually had # development performed on it. next unless project.repository_exists? - next unless project.repository.commit('master') + next unless project.repository.commit("master") seeder = Gitlab::Seeder::CycleAnalytics.new(project) seeder.seed! end - elsif ENV['CYCLE_ANALYTICS_PERF_TEST'] + elsif ENV["CYCLE_ANALYTICS_PERF_TEST"] seeder = Gitlab::Seeder::CycleAnalytics.new(Project.order(:id).first, perf: true) seeder.seed! - elsif ENV['CYCLE_ANALYTICS_POPULATE_METRICS_DIRECTLY'] + elsif ENV["CYCLE_ANALYTICS_POPULATE_METRICS_DIRECTLY"] seeder = Gitlab::Seeder::CycleAnalytics.new(Project.order(:id).first, perf: true) seeder.seed_metrics! else diff --git a/db/fixtures/development/18_abuse_reports.rb b/db/fixtures/development/18_abuse_reports.rb index 88d2f784852..759f9abad8a 100644 --- a/db/fixtures/development/18_abuse_reports.rb +++ b/db/fixtures/development/18_abuse_reports.rb @@ -11,11 +11,11 @@ module Db name: FFaker::Name.name, email: FFaker::Internet.email, confirmed_at: DateTime.now, - password: '12345678' + password: "12345678" ) - ::AbuseReport.create(reporter: ::User.take, user: reported_user, message: 'User sends spam') - print '.' + ::AbuseReport.create(reporter: ::User.take, user: reported_user, message: "User sends spam") + print "." end end end diff --git a/db/fixtures/development/19_environments.rb b/db/fixtures/development/19_environments.rb index 3e227928a29..2966dd3ee5b 100644 --- a/db/fixtures/development/19_environments.rb +++ b/db/fixtures/development/19_environments.rb @@ -1,4 +1,4 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" class Gitlab::Seeder::Environments def initialize(project) @@ -9,19 +9,19 @@ class Gitlab::Seeder::Environments @project.create_mock_deployment_service!(active: true) @project.create_mock_monitoring_service!(active: true) - create_master_deployments!('production') - create_master_deployments!('staging') + create_master_deployments!("production") + create_master_deployments!("staging") create_merge_request_review_deployments! end private def create_master_deployments!(name) - @project.repository.commits('master', limit: 4).map do |commit| + @project.repository.commits("master", limit: 4).map do |commit| create_deployment!( @project, name, - 'master', + "master", commit.id ) end @@ -37,7 +37,7 @@ class Gitlab::Seeder::Environments create_deployment!( merge_request.source_project, - "review/#{merge_request.source_branch.gsub(/[^a-zA-Z0-9]+/, '')}", + "review/#{merge_request.source_branch.gsub(/[^a-zA-Z0-9]+/, "")}", merge_request.source_branch, merge_request.diff_head_sha ) diff --git a/db/fixtures/development/20_nested_groups.rb b/db/fixtures/development/20_nested_groups.rb index 3d95e243f8a..da606c21fa9 100644 --- a/db/fixtures/development/20_nested_groups.rb +++ b/db/fixtures/development/20_nested_groups.rb @@ -1,28 +1,28 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" Sidekiq::Testing.inline! do Gitlab::Seeder.quiet do - flag = 'SEED_NESTED_GROUPS' + flag = "SEED_NESTED_GROUPS" if ENV[flag] project_urls = [ - 'https://android.googlesource.com/platform/hardware/broadcom/libbt.git', - 'https://android.googlesource.com/platform/hardware/broadcom/wlan.git', - 'https://android.googlesource.com/platform/hardware/bsp/bootloader/intel/edison-u-boot.git', - 'https://android.googlesource.com/platform/hardware/bsp/broadcom.git', - 'https://android.googlesource.com/platform/hardware/bsp/freescale.git', - 'https://android.googlesource.com/platform/hardware/bsp/imagination.git', - 'https://android.googlesource.com/platform/hardware/bsp/intel.git', - 'https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.1.git', - 'https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.4.git' + "https://android.googlesource.com/platform/hardware/broadcom/libbt.git", + "https://android.googlesource.com/platform/hardware/broadcom/wlan.git", + "https://android.googlesource.com/platform/hardware/bsp/bootloader/intel/edison-u-boot.git", + "https://android.googlesource.com/platform/hardware/bsp/broadcom.git", + "https://android.googlesource.com/platform/hardware/bsp/freescale.git", + "https://android.googlesource.com/platform/hardware/bsp/imagination.git", + "https://android.googlesource.com/platform/hardware/bsp/intel.git", + "https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.1.git", + "https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.4.git", ] user = User.admins.first project_urls.each_with_index do |url, i| - full_path = url.sub('https://android.googlesource.com/', '') - full_path = full_path.sub(/\.git\z/, '') - full_path, _, project_path = full_path.rpartition('/') + full_path = url.sub("https://android.googlesource.com/", "") + full_path = full_path.sub(/\.git\z/, "") + full_path, _, project_path = full_path.rpartition("/") group = Group.find_by_full_path(full_path) || Groups::NestedCreateService.new(user, group_path: full_path).execute @@ -32,16 +32,16 @@ Sidekiq::Testing.inline! do path: project_path, name: project_path, description: FFaker::Lorem.sentence, - visibility_level: Gitlab::VisibilityLevel.values.sample + visibility_level: Gitlab::VisibilityLevel.values.sample, } project = Projects::CreateService.new(user, params).execute project.send(:_run_after_commit_queue) if project.valid? - print '.' + print "." else - print 'F' + print "F" end end else diff --git a/db/fixtures/development/21_conversational_development_index_metrics.rb b/db/fixtures/development/21_conversational_development_index_metrics.rb index 4cd0a82ed1a..c2197969b79 100644 --- a/db/fixtures/development/21_conversational_development_index_metrics.rb +++ b/db/fixtures/development/21_conversational_development_index_metrics.rb @@ -32,9 +32,9 @@ Gitlab::Seeder.quiet do ) if conversational_development_index_metric.save - print '.' + print "." else puts conversational_development_index_metric.errors.full_messages - print 'F' + print "F" end end diff --git a/db/fixtures/development/22_labeled_issues_seed.rb b/db/fixtures/development/22_labeled_issues_seed.rb index 3730e9c7958..f7b5244a97f 100644 --- a/db/fixtures/development/22_labeled_issues_seed.rb +++ b/db/fixtures/development/22_labeled_issues_seed.rb @@ -1,7 +1,7 @@ # Creates a project with labeled issues for an user. # Run this single seed file using: rake db:seed_fu FILTER=labeled USER_ID=74. # If an USER_ID is not provided it will use the last created user. -require './spec/support/sidekiq' +require "./spec/support/sidekiq" class Gitlab::Seeder::LabeledIssues include ::Gitlab::Utils @@ -19,7 +19,7 @@ class Gitlab::Seeder::LabeledIssues create_issues(group) end - print '.' + print "." end private @@ -30,7 +30,7 @@ class Gitlab::Seeder::LabeledIssues group_params = { name: group_name, path: group_name, - description: FFaker::Lorem.sentence + description: FFaker::Lorem.sentence, } Groups::CreateService.new(@user, group_params).execute @@ -44,7 +44,7 @@ class Gitlab::Seeder::LabeledIssues namespace_id: group.id, name: project_name, description: FFaker::Lorem.sentence, - visibility_level: Gitlab::VisibilityLevel.values.sample + visibility_level: Gitlab::VisibilityLevel.values.sample, } Projects::CreateService.new(@user, params).execute @@ -78,8 +78,8 @@ class Gitlab::Seeder::LabeledIssues issue_params = { title: FFaker::Lorem.sentence(6), description: FFaker::Lorem.sentence, - state: 'opened', - label_ids: label_ids + state: "opened", + label_ids: label_ids, } @@ -90,7 +90,7 @@ class Gitlab::Seeder::LabeledIssues end Gitlab::Seeder.quiet do - user_id = ENV['USER_ID'] + user_id = ENV["USER_ID"] user = if user_id.present? diff --git a/db/fixtures/development/23_spam_logs.rb b/db/fixtures/development/23_spam_logs.rb index 81cc13e6b2d..ba18ba5e9e1 100644 --- a/db/fixtures/development/23_spam_logs.rb +++ b/db/fixtures/development/23_spam_logs.rb @@ -8,15 +8,16 @@ module Db Gitlab::Seeder.quiet do (::SpamLog.default_per_page + 3).times do |i| ::SpamLog.create( - user: self.random_user, + user: random_user, user_agent: FFaker::Lorem.sentence, source_ip: FFaker::Internet.ip_v4_address, title: FFaker::Lorem.sentence, description: FFaker::Lorem.paragraph, via_api: FFaker::Boolean.random, submitted_as_ham: FFaker::Boolean.random, - recaptcha_verified: FFaker::Boolean.random) - print '.' + recaptcha_verified: FFaker::Boolean.random + ) + print "." end end end diff --git a/db/fixtures/development/24_forks.rb b/db/fixtures/development/24_forks.rb index 5eb5956ec74..40d6c16673a 100644 --- a/db/fixtures/development/24_forks.rb +++ b/db/fixtures/development/24_forks.rb @@ -1,4 +1,4 @@ -require './spec/support/sidekiq' +require "./spec/support/sidekiq" Sidekiq::Testing.inline! do Gitlab::Seeder.quiet do @@ -13,9 +13,9 @@ Sidekiq::Testing.inline! do fork_project = Projects::ForkService.new(source_project, user, namespace: user.namespace).execute if fork_project.valid? - puts '.' + puts "." else - puts 'F' + puts "F" end end end diff --git a/db/fixtures/development/99_common_metrics.rb b/db/fixtures/development/99_common_metrics.rb index 1f39c0ce5a0..461444592ec 100644 --- a/db/fixtures/development/99_common_metrics.rb +++ b/db/fixtures/development/99_common_metrics.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require Rails.root.join('db/importers/common_metrics_importer.rb') +require Rails.root.join("db/importers/common_metrics_importer.rb") ::Importers::CommonMetricsImporter.new.execute diff --git a/db/fixtures/production/002_admin.rb b/db/fixtures/production/002_admin.rb index 1c7c89f7bbd..35b92e176ff 100644 --- a/db/fixtures/production/002_admin.rb +++ b/db/fixtures/production/002_admin.rb @@ -1,15 +1,15 @@ user_args = { - email: ENV['GITLAB_ROOT_EMAIL'].presence || 'admin@example.com', - name: 'Administrator', - username: 'root', - admin: true + email: ENV["GITLAB_ROOT_EMAIL"].presence || "admin@example.com", + name: "Administrator", + username: "root", + admin: true, } -if ENV['GITLAB_ROOT_PASSWORD'].blank? +if ENV["GITLAB_ROOT_PASSWORD"].blank? user_args[:password_automatically_set] = true user_args[:force_random_password] = true else - user_args[:password] = ENV['GITLAB_ROOT_PASSWORD'] + user_args[:password] = ENV["GITLAB_ROOT_PASSWORD"] end # Only admins can create other admin users in Users::CreateService so to solve diff --git a/db/fixtures/production/010_settings.rb b/db/fixtures/production/010_settings.rb index 7626cdb0b9c..da91af57ead 100644 --- a/db/fixtures/production/010_settings.rb +++ b/db/fixtures/production/010_settings.rb @@ -12,15 +12,15 @@ def save(settings, topic) end end -if ENV['GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN'].present? +if ENV["GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN"].present? settings = Gitlab::CurrentSettings.current_application_settings - settings.set_runners_registration_token(ENV['GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN']) - save(settings, 'Runner Registration Token') + settings.set_runners_registration_token(ENV["GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN"]) + save(settings, "Runner Registration Token") end -if ENV['GITLAB_PROMETHEUS_METRICS_ENABLED'].present? +if ENV["GITLAB_PROMETHEUS_METRICS_ENABLED"].present? settings = Gitlab::CurrentSettings.current_application_settings - value = Gitlab::Utils.to_boolean(ENV['GITLAB_PROMETHEUS_METRICS_ENABLED']) || false + value = Gitlab::Utils.to_boolean(ENV["GITLAB_PROMETHEUS_METRICS_ENABLED"]) || false settings.prometheus_metrics_enabled = value - save(settings, 'Prometheus metrics enabled flag') + save(settings, "Prometheus metrics enabled flag") end diff --git a/db/fixtures/production/999_common_metrics.rb b/db/fixtures/production/999_common_metrics.rb index 1f39c0ce5a0..461444592ec 100644 --- a/db/fixtures/production/999_common_metrics.rb +++ b/db/fixtures/production/999_common_metrics.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require Rails.root.join('db/importers/common_metrics_importer.rb') +require Rails.root.join("db/importers/common_metrics_importer.rb") ::Importers::CommonMetricsImporter.new.execute diff --git a/db/importers/common_metrics_importer.rb b/db/importers/common_metrics_importer.rb index deadd653ae9..28edcc5c3a4 100644 --- a/db/importers/common_metrics_importer.rb +++ b/db/importers/common_metrics_importer.rb @@ -14,21 +14,21 @@ module Importers # custom groups business: 0, response: 1, - system: 2 + system: 2, } scope :common, -> { where(common: true) } GROUP_TITLES = { - business: _('Business metrics (Custom)'), - response: _('Response metrics (Custom)'), - system: _('System metrics (Custom)'), - nginx_ingress_vts: _('Response metrics (NGINX Ingress VTS)'), - nginx_ingress: _('Response metrics (NGINX Ingress)'), - ha_proxy: _('Response metrics (HA Proxy)'), - aws_elb: _('Response metrics (AWS ELB)'), - nginx: _('Response metrics (NGINX)'), - kubernetes: _('System metrics (Kubernetes)') + business: _("Business metrics (Custom)"), + response: _("Response metrics (Custom)"), + system: _("System metrics (Custom)"), + nginx_ingress_vts: _("Response metrics (NGINX Ingress VTS)"), + nginx_ingress: _("Response metrics (NGINX Ingress)"), + ha_proxy: _("Response metrics (HA Proxy)"), + aws_elb: _("Response metrics (AWS ELB)"), + nginx: _("Response metrics (NGINX)"), + kubernetes: _("System metrics (Kubernetes)"), }.freeze end @@ -37,8 +37,8 @@ module Importers attr_reader :content - def initialize(filename = 'common_metrics.yml') - @content = YAML.load_file(Rails.root.join('config', 'prometheus', filename)) + def initialize(filename = "common_metrics.yml") + @content = YAML.load_file(Rails.root.join("config", "prometheus", filename)) end def execute @@ -60,31 +60,33 @@ module Importers def process_group(group, &blk) attributes = { - group: find_group_title_key(group['group']) + group: find_group_title_key(group["group"]), } - group['metrics'].map do |metric| + group["metrics"].map do |metric| process_metric(metric, attributes, &blk) end end def process_metric(metric, attributes, &blk) attributes = attributes.merge( - title: metric['title'], - y_label: metric['y_label']) + title: metric["title"], + y_label: metric["y_label"] + ) - metric['queries'].map do |query| + metric["queries"].map do |query| process_metric_query(query, attributes, &blk) end end def process_metric_query(query, attributes, &blk) attributes = attributes.merge( - legend: query['label'], - query: query['query_range'], - unit: query['unit']) + legend: query["label"], + query: query["query_range"], + unit: query["unit"] + ) - yield(query['id'], attributes) + yield(query["id"], attributes) end def find_or_build_metric!(id) diff --git a/db/migrate/20140407135544_fix_namespaces.rb b/db/migrate/20140407135544_fix_namespaces.rb index b16d65c4b51..1258dc914f7 100644 --- a/db/migrate/20140407135544_fix_namespaces.rb +++ b/db/migrate/20140407135544_fix_namespaces.rb @@ -2,11 +2,11 @@ class FixNamespaces < ActiveRecord::Migration[4.2] DOWNTIME = false def up - namespaces = exec_query('SELECT id, path FROM namespaces WHERE name <> path and type is null') + namespaces = exec_query("SELECT id, path FROM namespaces WHERE name <> path and type is null") namespaces.each do |row| - id = row['id'] - path = row['path'] + id = row["id"] + path = row["path"] exec_query("UPDATE namespaces SET name = '#{path}' WHERE id = #{id}") end end diff --git a/db/migrate/20140415124820_limits_to_mysql.rb b/db/migrate/20140415124820_limits_to_mysql.rb index 3f6e62617c5..fa584f50d0b 100644 --- a/db/migrate/20140415124820_limits_to_mysql.rb +++ b/db/migrate/20140415124820_limits_to_mysql.rb @@ -1 +1 @@ -require_relative 'limits_to_mysql' +require_relative "limits_to_mysql" diff --git a/db/migrate/20140729145339_migrate_project_tags.rb b/db/migrate/20140729145339_migrate_project_tags.rb index 711a2d262aa..6c4303cf8f3 100644 --- a/db/migrate/20140729145339_migrate_project_tags.rb +++ b/db/migrate/20140729145339_migrate_project_tags.rb @@ -1,9 +1,9 @@ class MigrateProjectTags < ActiveRecord::Migration[4.2] def up - ActsAsTaggableOn::Tagging.where(taggable_type: 'Project', context: 'labels').update_all(context: 'tags') + ActsAsTaggableOn::Tagging.where(taggable_type: "Project", context: "labels").update_all(context: "tags") end def down - ActsAsTaggableOn::Tagging.where(taggable_type: 'Project', context: 'tags').update_all(context: 'labels') + ActsAsTaggableOn::Tagging.where(taggable_type: "Project", context: "tags").update_all(context: "labels") end end diff --git a/db/migrate/20150411000035_fix_identities.rb b/db/migrate/20150411000035_fix_identities.rb index a449fc51ecc..21fd3df7a6d 100644 --- a/db/migrate/20150411000035_fix_identities.rb +++ b/db/migrate/20150411000035_fix_identities.rb @@ -10,22 +10,22 @@ class FixIdentities < ActiveRecord::Migration[4.2] # whatever the code would have interpreted it as, i.e. as a reference to # the first LDAP server specified in gitlab.yml / gitlab.rb. new_provider = if Gitlab.config.ldap.enabled - first_ldap_server = Gitlab.config.ldap.servers.values.first - first_ldap_server['provider_name'] - else - 'ldapmain' - end + first_ldap_server = Gitlab.config.ldap.servers.values.first + first_ldap_server["provider_name"] + else + "ldapmain" + end # Delete duplicate identities # We use a sort of self-join to find rows in identities which match on # user_id but where one has provider 'ldap'. We delete the duplicate row # with provider 'ldap'. - delete_statement = '' + delete_statement = "" case adapter_name.downcase when /^mysql/ - delete_statement << 'DELETE FROM id1 USING identities AS id1, identities AS id2' - when 'postgresql' - delete_statement << 'DELETE FROM identities AS id1 USING identities AS id2' + delete_statement << "DELETE FROM id1 USING identities AS id1, identities AS id2" + when "postgresql" + delete_statement << "DELETE FROM identities AS id1 USING identities AS id2" else raise "Unknown DB adapter: #{adapter_name}" end @@ -35,7 +35,7 @@ class FixIdentities < ActiveRecord::Migration[4.2] # Update legacy identities execute "UPDATE identities SET provider = '#{new_provider}' WHERE provider = 'ldap'" - if table_exists?('ldap_group_links') + if table_exists?("ldap_group_links") execute "UPDATE ldap_group_links SET provider = '#{new_provider}' WHERE provider IS NULL OR provider = 'ldap'" end end diff --git a/db/migrate/20150423033240_add_default_project_visibililty_to_application_settings.rb b/db/migrate/20150423033240_add_default_project_visibililty_to_application_settings.rb index e0f35da422a..61cbb07c226 100644 --- a/db/migrate/20150423033240_add_default_project_visibililty_to_application_settings.rb +++ b/db/migrate/20150423033240_add_default_project_visibililty_to_application_settings.rb @@ -1,7 +1,7 @@ class AddDefaultProjectVisibililtyToApplicationSettings < ActiveRecord::Migration[4.2] def up add_column :application_settings, :default_project_visibility, :integer - visibility = Settings.gitlab.default_projects_features['visibility_level'] + visibility = Settings.gitlab.default_projects_features["visibility_level"] execute("update application_settings set default_project_visibility = #{visibility}") end diff --git a/db/migrate/20150425173433_add_default_snippet_visibility_to_app_settings.rb b/db/migrate/20150425173433_add_default_snippet_visibility_to_app_settings.rb index a3a86d26767..1927a4fb1e8 100644 --- a/db/migrate/20150425173433_add_default_snippet_visibility_to_app_settings.rb +++ b/db/migrate/20150425173433_add_default_snippet_visibility_to_app_settings.rb @@ -1,7 +1,7 @@ class AddDefaultSnippetVisibilityToAppSettings < ActiveRecord::Migration[4.2] def up add_column :application_settings, :default_snippet_visibility, :integer - visibility = Settings.gitlab.default_projects_features['visibility_level'] + visibility = Settings.gitlab.default_projects_features["visibility_level"] execute("update application_settings set default_snippet_visibility = #{visibility}") end diff --git a/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb b/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb index 4a085ff06f3..0d14eb42c4b 100644 --- a/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb +++ b/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb @@ -1,6 +1,6 @@ class AddDefaultOtpRequiredForLoginValue < ActiveRecord::Migration[4.2] def up - execute %q{UPDATE users SET otp_required_for_login = FALSE WHERE otp_required_for_login IS NULL} + execute "UPDATE users SET otp_required_for_login = FALSE WHERE otp_required_for_login IS NULL" change_column :users, :otp_required_for_login, :boolean, default: false, null: false end diff --git a/db/migrate/20150924125436_migrate_project_id_for_ci_commits.rb b/db/migrate/20150924125436_migrate_project_id_for_ci_commits.rb index ff31e70874f..93a6ab0b97f 100644 --- a/db/migrate/20150924125436_migrate_project_id_for_ci_commits.rb +++ b/db/migrate/20150924125436_migrate_project_id_for_ci_commits.rb @@ -1,6 +1,6 @@ class MigrateProjectIdForCiCommits < ActiveRecord::Migration[4.2] def up - subquery = 'SELECT gitlab_id FROM ci_projects WHERE ci_projects.id = ci_commits.project_id' + subquery = "SELECT gitlab_id FROM ci_projects WHERE ci_projects.id = ci_commits.project_id" execute("UPDATE ci_commits SET gl_project_id=(#{subquery}) WHERE gl_project_id IS NULL") end end diff --git a/db/migrate/20151020173516_ci_limits_to_mysql.rb b/db/migrate/20151020173516_ci_limits_to_mysql.rb index 573922b851b..eab2201c2fb 100644 --- a/db/migrate/20151020173516_ci_limits_to_mysql.rb +++ b/db/migrate/20151020173516_ci_limits_to_mysql.rb @@ -1,6 +1,6 @@ class CiLimitsToMysql < ActiveRecord::Migration[4.2] def change - return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/ + return unless ActiveRecord::Base.configurations[Rails.env]["adapter"] =~ /^mysql/ # CI change_column :ci_builds, :trace, :text, limit: 1073741823 diff --git a/db/migrate/20151023144219_remove_satellites.rb b/db/migrate/20151023144219_remove_satellites.rb index 2d1310b0208..4701817cd97 100644 --- a/db/migrate/20151023144219_remove_satellites.rb +++ b/db/migrate/20151023144219_remove_satellites.rb @@ -1,11 +1,11 @@ -require 'fileutils' +require "fileutils" class RemoveSatellites < ActiveRecord::Migration[4.2] def up - satellites = Gitlab.config['satellites'] + satellites = Gitlab.config["satellites"] return if satellites.nil? - satellites_path = satellites['path'] + satellites_path = satellites["path"] return if satellites_path.nil? FileUtils.rm_rf(satellites_path) diff --git a/db/migrate/20151209144329_migrate_ci_web_hooks.rb b/db/migrate/20151209144329_migrate_ci_web_hooks.rb index 7562735cb1e..7ab26abdbca 100644 --- a/db/migrate/20151209144329_migrate_ci_web_hooks.rb +++ b/db/migrate/20151209144329_migrate_ci_web_hooks.rb @@ -3,11 +3,11 @@ class MigrateCiWebHooks < ActiveRecord::Migration[4.2] def up execute( - 'INSERT INTO web_hooks (url, project_id, type, created_at, updated_at, push_events, issues_events, merge_requests_events, tag_push_events, note_events, build_events) ' \ + "INSERT INTO web_hooks (url, project_id, type, created_at, updated_at, push_events, issues_events, merge_requests_events, tag_push_events, note_events, build_events) " \ "SELECT ci_web_hooks.url, projects.id, 'ProjectHook', ci_web_hooks.created_at, ci_web_hooks.updated_at, " \ "#{false_value}, #{false_value}, #{false_value}, #{false_value}, #{false_value}, #{true_value} FROM ci_web_hooks " \ - 'JOIN ci_projects ON ci_web_hooks.project_id = ci_projects.id ' \ - 'JOIN projects ON ci_projects.gitlab_id = projects.id' + "JOIN ci_projects ON ci_web_hooks.project_id = ci_projects.id " \ + "JOIN projects ON ci_projects.gitlab_id = projects.id" ) end diff --git a/db/migrate/20151209145909_migrate_ci_emails.rb b/db/migrate/20151209145909_migrate_ci_emails.rb index a1f51c55a55..333f68b4398 100644 --- a/db/migrate/20151209145909_migrate_ci_emails.rb +++ b/db/migrate/20151209145909_migrate_ci_emails.rb @@ -6,16 +6,16 @@ class MigrateCiEmails < ActiveRecord::Migration[4.2] # It "manually" constructs the properties (JSON-encoded) # Migrating all ci_projects e-mail related columns execute( - 'INSERT INTO services (project_id, type, created_at, updated_at, active, push_events, issues_events, merge_requests_events, tag_push_events, note_events, build_events, properties) ' \ + "INSERT INTO services (project_id, type, created_at, updated_at, active, push_events, issues_events, merge_requests_events, tag_push_events, note_events, build_events, properties) " \ "SELECT projects.id, 'BuildsEmailService', ci_services.created_at, ci_services.updated_at, " \ "#{true_value}, #{false_value}, #{false_value}, #{false_value}, #{false_value}, #{false_value}, #{true_value}, " \ - "CONCAT('{\"notify_only_broken_builds\":\"', #{convert_bool('ci_projects.email_only_broken_builds')}, " \ - "'\",\"add_pusher\":\"', #{convert_bool('ci_projects.email_add_pusher')}, " \ - "'\",\"recipients\":\"', #{escape_text('ci_projects.email_recipients')}, " \ + "CONCAT('{\"notify_only_broken_builds\":\"', #{convert_bool("ci_projects.email_only_broken_builds")}, " \ + "'\",\"add_pusher\":\"', #{convert_bool("ci_projects.email_add_pusher")}, " \ + "'\",\"recipients\":\"', #{escape_text("ci_projects.email_recipients")}, " \ "'\"}') " \ - 'FROM ci_services ' \ - 'JOIN ci_projects ON ci_services.project_id = ci_projects.id ' \ - 'JOIN projects ON ci_projects.gitlab_id = projects.id ' \ + "FROM ci_services " \ + "JOIN ci_projects ON ci_services.project_id = ci_projects.id " \ + "JOIN projects ON ci_projects.gitlab_id = projects.id " \ "WHERE ci_services.type = 'Ci::MailService' AND ci_services.active" ) end @@ -39,7 +39,7 @@ class MigrateCiEmails < ActiveRecord::Migration[4.2] "CASE WHEN #{name} IS TRUE THEN '1' ELSE '0' END" else # MySQL uses TINYINT - "#{name}" + name.to_s end end end diff --git a/db/migrate/20151210125232_migrate_ci_slack_service.rb b/db/migrate/20151210125232_migrate_ci_slack_service.rb index 72c90f92377..83bcb02e275 100644 --- a/db/migrate/20151210125232_migrate_ci_slack_service.rb +++ b/db/migrate/20151210125232_migrate_ci_slack_service.rb @@ -2,15 +2,15 @@ class MigrateCiSlackService < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers def up - properties_query = 'SELECT properties FROM ci_services ' \ - 'JOIN ci_projects ON ci_services.project_id=ci_projects.id ' \ + properties_query = "SELECT properties FROM ci_services " \ + "JOIN ci_projects ON ci_services.project_id=ci_projects.id " \ "WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::SlackService' AND ci_services.active " \ - 'LIMIT 1' + "LIMIT 1" - active_query = 'SELECT 1 FROM ci_services ' \ - 'JOIN ci_projects ON ci_services.project_id=ci_projects.id ' \ + active_query = "SELECT 1 FROM ci_services " \ + "JOIN ci_projects ON ci_services.project_id=ci_projects.id " \ "WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::SlackService' AND ci_services.active " \ - 'LIMIT 1' + "LIMIT 1" # We update the service since services are always generated for project, even if they are inactive # Activate service and migrate properties if currently the service is not active diff --git a/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb b/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb index 5ec0798c38f..f273dbf5fd9 100644 --- a/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb +++ b/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb @@ -4,14 +4,14 @@ class MigrateCiHipChatService < ActiveRecord::Migration[4.2] def up # From properties strip `hipchat_` key properties_query = "SELECT REPLACE(properties, '\"hipchat_', '\"') FROM ci_services " \ - 'JOIN ci_projects ON ci_services.project_id=ci_projects.id ' \ + "JOIN ci_projects ON ci_services.project_id=ci_projects.id " \ "WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::HipChatService' AND ci_services.active " \ - 'LIMIT 1' + "LIMIT 1" - active_query = 'SELECT 1 FROM ci_services ' \ - 'JOIN ci_projects ON ci_services.project_id=ci_projects.id ' \ + active_query = "SELECT 1 FROM ci_services " \ + "JOIN ci_projects ON ci_services.project_id=ci_projects.id " \ "WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::HipChatService' AND ci_services.active " \ - 'LIMIT 1' + "LIMIT 1" # We update the service since services are always generated for project, even if they are inactive # Activate service and migrate properties if currently the service is not active diff --git a/db/migrate/20151210125930_migrate_ci_to_project.rb b/db/migrate/20151210125930_migrate_ci_to_project.rb index f7573ad1a8d..b6db8f81d15 100644 --- a/db/migrate/20151210125930_migrate_ci_to_project.rb +++ b/db/migrate/20151210125930_migrate_ci_to_project.rb @@ -1,16 +1,16 @@ class MigrateCiToProject < ActiveRecord::Migration[4.2] def up - migrate_project_id_for_table('ci_runner_projects') - migrate_project_id_for_table('ci_triggers') - migrate_project_id_for_table('ci_variables') + migrate_project_id_for_table("ci_runner_projects") + migrate_project_id_for_table("ci_triggers") + migrate_project_id_for_table("ci_variables") migrate_project_id_for_builds - migrate_project_column('id', 'ci_id') - migrate_project_column('shared_runners_enabled', 'shared_runners_enabled') - migrate_project_column('token', 'runners_token') - migrate_project_column('coverage_regex', 'build_coverage_regex') - migrate_project_column('allow_git_fetch', 'build_allow_git_fetch') - migrate_project_column('timeout', 'build_timeout') + migrate_project_column("id", "ci_id") + migrate_project_column("shared_runners_enabled", "shared_runners_enabled") + migrate_project_column("token", "runners_token") + migrate_project_column("coverage_regex", "build_coverage_regex") + migrate_project_column("allow_git_fetch", "build_allow_git_fetch") + migrate_project_column("timeout", "build_timeout") migrate_ci_service end @@ -24,14 +24,14 @@ class MigrateCiToProject < ActiveRecord::Migration[4.2] end def migrate_project_id_for_builds - subquery = 'SELECT gl_project_id FROM ci_commits WHERE ci_commits.id = ci_builds.commit_id' + subquery = "SELECT gl_project_id FROM ci_commits WHERE ci_commits.id = ci_builds.commit_id" execute("UPDATE ci_builds SET gl_project_id=(#{subquery}) WHERE gl_project_id IS NULL") end def migrate_project_column(column, new_column = nil) new_column ||= column subquery = "SELECT ci_projects.#{column} FROM ci_projects WHERE projects.id = ci_projects.gitlab_id " \ - 'ORDER BY ci_projects.updated_at DESC LIMIT 1' + "ORDER BY ci_projects.updated_at DESC LIMIT 1" execute("UPDATE projects SET #{new_column}=(#{subquery}) WHERE (#{subquery}) IS NOT NULL") end diff --git a/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb b/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb index 6254017615b..e0d0b45bdd3 100644 --- a/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb +++ b/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb @@ -39,7 +39,7 @@ class RemoveDotAtomPathEndingOfProjects < ActiveRecord::Migration[4.2] private def cleaned_path - @_cleaned_path ||= @path.gsub(/\.atom\z/, '-atom') + @_cleaned_path ||= @path.gsub(/\.atom\z/, "-atom") end def path_exists?(path) @@ -53,7 +53,7 @@ class RemoveDotAtomPathEndingOfProjects < ActiveRecord::Migration[4.2] def up projects_with_dot_atom.each do |project| - project_path = ProjectPath.new(project['path'], project['id'], project['namespace_path'], project['namespace_id']) + project_path = ProjectPath.new(project["path"], project["id"], project["namespace_path"], project["namespace_id"]) clean_path(project_path) if rename_project_repo(project_path) end end diff --git a/db/migrate/20160328115649_migrate_new_notification_setting.rb b/db/migrate/20160328115649_migrate_new_notification_setting.rb index 5ba09e75145..5223c68b9e1 100644 --- a/db/migrate/20160328115649_migrate_new_notification_setting.rb +++ b/db/migrate/20160328115649_migrate_new_notification_setting.rb @@ -7,7 +7,7 @@ # class MigrateNewNotificationSetting < ActiveRecord::Migration[4.2] def up - timestamp = Time.now.strftime('%F %T') + timestamp = Time.now.strftime("%F %T") execute "INSERT INTO notification_settings ( user_id, source_id, source_type, level, created_at, updated_at ) SELECT user_id, source_id, source_type, notification_level, '#{timestamp}', '#{timestamp}' FROM members WHERE user_id IS NOT NULL" end diff --git a/db/migrate/20160415062917_create_personal_access_tokens.rb b/db/migrate/20160415062917_create_personal_access_tokens.rb index 43599db799e..b0fb68b002d 100644 --- a/db/migrate/20160415062917_create_personal_access_tokens.rb +++ b/db/migrate/20160415062917_create_personal_access_tokens.rb @@ -3,7 +3,7 @@ class CreatePersonalAccessTokens < ActiveRecord::Migration[4.2] def change create_table :personal_access_tokens do |t| t.references :user, index: true, foreign_key: true, null: false - t.string :token, index: { unique: true }, null: false + t.string :token, index: {unique: true}, null: false t.string :name, null: false t.boolean :revoked, default: false t.datetime :expires_at diff --git a/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb b/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb index af2820986f0..1c4282a4cae 100644 --- a/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb +++ b/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb @@ -18,7 +18,7 @@ class ConvertAwardNoteToEmojiAward < ActiveRecord::Migration[4.2] def migrate_postgresql connection.transaction do - execute 'LOCK notes IN EXCLUSIVE MODE' + execute "LOCK notes IN EXCLUSIVE MODE" execute "INSERT INTO award_emoji (awardable_type, awardable_id, user_id, name, created_at, updated_at) (SELECT noteable_type, noteable_id, author_id, note, created_at, updated_at FROM notes WHERE is_award = true)" execute "DELETE FROM notes WHERE is_award = true" remove_column :notes, :is_award, :boolean @@ -26,11 +26,11 @@ class ConvertAwardNoteToEmojiAward < ActiveRecord::Migration[4.2] end def migrate_mysql - execute 'LOCK TABLES notes WRITE, award_emoji WRITE;' - execute 'INSERT INTO award_emoji (awardable_type, awardable_id, user_id, name, created_at, updated_at) (SELECT noteable_type, noteable_id, author_id, note, created_at, updated_at FROM notes WHERE is_award = true);' + execute "LOCK TABLES notes WRITE, award_emoji WRITE;" + execute "INSERT INTO award_emoji (awardable_type, awardable_id, user_id, name, created_at, updated_at) (SELECT noteable_type, noteable_id, author_id, note, created_at, updated_at FROM notes WHERE is_award = true);" execute "DELETE FROM notes WHERE is_award = true" remove_column :notes, :is_award, :boolean ensure - execute 'UNLOCK TABLES' + execute "UNLOCK TABLES" end end diff --git a/db/migrate/20160419122101_add_only_allow_merge_if_build_succeeds_to_projects.rb b/db/migrate/20160419122101_add_only_allow_merge_if_build_succeeds_to_projects.rb index cf842a684a6..f8e8397a0be 100644 --- a/db/migrate/20160419122101_add_only_allow_merge_if_build_succeeds_to_projects.rb +++ b/db/migrate/20160419122101_add_only_allow_merge_if_build_succeeds_to_projects.rb @@ -5,9 +5,9 @@ class AddOnlyAllowMergeIfBuildSucceedsToProjects < ActiveRecord::Migration[4.2] def up add_column_with_default(:projects, - :only_allow_merge_if_build_succeeds, - :boolean, - default: false) + :only_allow_merge_if_build_succeeds, + :boolean, + default: false) end def down diff --git a/db/migrate/20160504112519_add_run_untagged_to_ci_runner.rb b/db/migrate/20160504112519_add_run_untagged_to_ci_runner.rb index 03ec29b9951..f04e98407ee 100644 --- a/db/migrate/20160504112519_add_run_untagged_to_ci_runner.rb +++ b/db/migrate/20160504112519_add_run_untagged_to_ci_runner.rb @@ -4,7 +4,7 @@ class AddRunUntaggedToCiRunner < ActiveRecord::Migration[4.2] def up add_column_with_default(:ci_runners, :run_untagged, :boolean, - default: true, allow_null: false) + default: true, allow_null: false) end def down diff --git a/db/migrate/20160509091049_add_locked_to_ci_runner.rb b/db/migrate/20160509091049_add_locked_to_ci_runner.rb index e19db5a4504..10c5de74b70 100644 --- a/db/migrate/20160509091049_add_locked_to_ci_runner.rb +++ b/db/migrate/20160509091049_add_locked_to_ci_runner.rb @@ -4,7 +4,7 @@ class AddLockedToCiRunner < ActiveRecord::Migration[4.2] def up add_column_with_default(:ci_runners, :locked, :boolean, - default: false, allow_null: false) + default: false, allow_null: false) end def down diff --git a/db/migrate/20160603180330_remove_duplicated_notification_settings.rb b/db/migrate/20160603180330_remove_duplicated_notification_settings.rb index 0d8c4bf011c..b9c35307c39 100644 --- a/db/migrate/20160603180330_remove_duplicated_notification_settings.rb +++ b/db/migrate/20160603180330_remove_duplicated_notification_settings.rb @@ -1,6 +1,6 @@ class RemoveDuplicatedNotificationSettings < ActiveRecord::Migration[4.2] def up - duplicates = exec_query(%Q{ + duplicates = exec_query(%{ SELECT user_id, source_type, source_id FROM notification_settings GROUP BY user_id, source_type, source_id @@ -8,11 +8,11 @@ class RemoveDuplicatedNotificationSettings < ActiveRecord::Migration[4.2] }) duplicates.each do |row| - uid = row['user_id'] - stype = connection.quote(row['source_type']) - sid = row['source_id'] + uid = row["user_id"] + stype = connection.quote(row["source_type"]) + sid = row["source_id"] - execute(%Q{ + execute(%{ DELETE FROM notification_settings WHERE user_id = #{uid} AND source_type = #{stype} diff --git a/db/migrate/20160608195742_add_repository_storage_to_projects.rb b/db/migrate/20160608195742_add_repository_storage_to_projects.rb index 2b20c9fbd5f..4586b2c7141 100644 --- a/db/migrate/20160608195742_add_repository_storage_to_projects.rb +++ b/db/migrate/20160608195742_add_repository_storage_to_projects.rb @@ -4,7 +4,7 @@ class AddRepositoryStorageToProjects < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - add_column_with_default(:projects, :repository_storage, :string, default: 'default') + add_column_with_default(:projects, :repository_storage, :string, default: "default") end def down diff --git a/db/migrate/20160608211215_add_user_default_external_to_application_settings.rb b/db/migrate/20160608211215_add_user_default_external_to_application_settings.rb index 9b5cfc67d5a..614f773da20 100644 --- a/db/migrate/20160608211215_add_user_default_external_to_application_settings.rb +++ b/db/migrate/20160608211215_add_user_default_external_to_application_settings.rb @@ -4,7 +4,7 @@ class AddUserDefaultExternalToApplicationSettings < ActiveRecord::Migration[4.2] def up add_column_with_default(:application_settings, :user_default_external, :boolean, - default: false, allow_null: false) + default: false, allow_null: false) end def down diff --git a/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb b/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb index 1ac65997403..22c624c4a86 100644 --- a/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb +++ b/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb @@ -1,7 +1,7 @@ # rubocop:disable Migration/RemoveColumn class RemoveDeprecatedIssuesTrackerColumnsFromProjects < ActiveRecord::Migration[4.2] def change - remove_column :projects, :issues_tracker, :string, default: 'gitlab', null: false + remove_column :projects, :issues_tracker, :string, default: "gitlab", null: false remove_column :projects, :issues_tracker_id, :string end end diff --git a/db/migrate/20160610201627_migrate_users_notification_level.rb b/db/migrate/20160610201627_migrate_users_notification_level.rb index 553b7f074f2..589fc7f9ce9 100644 --- a/db/migrate/20160610201627_migrate_users_notification_level.rb +++ b/db/migrate/20160610201627_migrate_users_notification_level.rb @@ -7,7 +7,7 @@ class MigrateUsersNotificationLevel < ActiveRecord::Migration[4.2] DOWNTIME = false def up - execute(%Q{ + execute(%{ INSERT INTO notification_settings (user_id, level, created_at, updated_at) (SELECT id, notification_level, created_at, updated_at FROM users WHERE notification_level != 1) @@ -17,7 +17,7 @@ class MigrateUsersNotificationLevel < ActiveRecord::Migration[4.2] # Migrates from notification settings back to user notification_level # If no value is found the default level of 1 will be used def down - execute(%Q{ + execute(%{ UPDATE users u SET notification_level = COALESCE((SELECT level FROM notification_settings WHERE user_id = u.id AND source_type IS NULL), 1) }) diff --git a/db/migrate/20160614182521_add_repository_storage_to_application_settings.rb b/db/migrate/20160614182521_add_repository_storage_to_application_settings.rb index a1bc0e5cd86..3b83e3630eb 100644 --- a/db/migrate/20160614182521_add_repository_storage_to_application_settings.rb +++ b/db/migrate/20160614182521_add_repository_storage_to_application_settings.rb @@ -1,5 +1,5 @@ class AddRepositoryStorageToApplicationSettings < ActiveRecord::Migration[4.2] def change - add_column :application_settings, :repository_storage, :string, default: 'default' + add_column :application_settings, :repository_storage, :string, default: "default" end end diff --git a/db/migrate/20160616102642_remove_duplicated_keys.rb b/db/migrate/20160616102642_remove_duplicated_keys.rb index 0b896108292..8b1e78f2463 100644 --- a/db/migrate/20160616102642_remove_duplicated_keys.rb +++ b/db/migrate/20160616102642_remove_duplicated_keys.rb @@ -1,8 +1,8 @@ class RemoveDuplicatedKeys < ActiveRecord::Migration[4.2] def up select_all("SELECT fingerprint FROM #{quote_table_name(:keys)} GROUP BY fingerprint HAVING COUNT(*) > 1").each do |row| - fingerprint = connection.quote(row['fingerprint']) - execute(%Q{ + fingerprint = connection.quote(row["fingerprint"]) + execute(%{ DELETE FROM #{quote_table_name(:keys)} WHERE fingerprint = #{fingerprint} AND id != ( diff --git a/db/migrate/20160705054938_add_protected_branches_push_access.rb b/db/migrate/20160705054938_add_protected_branches_push_access.rb index 314d90efa90..8834143c74f 100644 --- a/db/migrate/20160705054938_add_protected_branches_push_access.rb +++ b/db/migrate/20160705054938_add_protected_branches_push_access.rb @@ -7,7 +7,7 @@ class AddProtectedBranchesPushAccess < ActiveRecord::Migration[4.2] def change create_table :protected_branch_push_access_levels do |t| - t.references :protected_branch, index: { name: "index_protected_branch_push_access" }, foreign_key: true, null: false + t.references :protected_branch, index: {name: "index_protected_branch_push_access"}, foreign_key: true, null: false # Gitlab::Access::MAINTAINER == 40 t.integer :access_level, default: 40, null: false diff --git a/db/migrate/20160705054952_add_protected_branches_merge_access.rb b/db/migrate/20160705054952_add_protected_branches_merge_access.rb index 672e0e291db..d71bed22e95 100644 --- a/db/migrate/20160705054952_add_protected_branches_merge_access.rb +++ b/db/migrate/20160705054952_add_protected_branches_merge_access.rb @@ -7,7 +7,7 @@ class AddProtectedBranchesMergeAccess < ActiveRecord::Migration[4.2] def change create_table :protected_branch_merge_access_levels do |t| - t.references :protected_branch, index: { name: "index_protected_branch_merge_access" }, foreign_key: true, null: false + t.references :protected_branch, index: {name: "index_protected_branch_merge_access"}, foreign_key: true, null: false # Gitlab::Access::MAINTAINER == 40 t.integer :access_level, default: 40, null: false diff --git a/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb b/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb index 0b553182a81..2ae64d64fd9 100644 --- a/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb +++ b/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb @@ -16,6 +16,6 @@ class RemoveAwardEmojisWithNoUser < ActiveRecord::Migration[4.2] # disable_ddl_transaction! def up - AwardEmoji.joins('LEFT JOIN users ON users.id = user_id').where('users.id IS NULL').destroy_all # rubocop: disable DestroyAll + AwardEmoji.joins("LEFT JOIN users ON users.id = user_id").where("users.id IS NULL").destroy_all # rubocop: disable DestroyAll end end diff --git a/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb b/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb index d8b4696a246..40772b9056c 100644 --- a/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb +++ b/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb @@ -9,7 +9,7 @@ class MergeRequestDiffRemoveUniq < ActiveRecord::Migration[4.2] DOWNTIME = false def up - constraint_name = 'merge_request_diffs_merge_request_id_key' + constraint_name = "merge_request_diffs_merge_request_id_key" transaction do if index_exists?(:merge_request_diffs, :merge_request_id) diff --git a/db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb b/db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb index fc3e9f03c74..ef90af06adf 100644 --- a/db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb +++ b/db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb @@ -7,7 +7,7 @@ class AddPipelineEventsToWebHooks < ActiveRecord::Migration[4.2] def up add_column_with_default(:web_hooks, :pipeline_events, :boolean, - default: false, allow_null: false) + default: false, allow_null: false) end def down diff --git a/db/migrate/20160728103734_add_pipeline_events_to_services.rb b/db/migrate/20160728103734_add_pipeline_events_to_services.rb index 421859ff5fd..10ccf20ad5a 100644 --- a/db/migrate/20160728103734_add_pipeline_events_to_services.rb +++ b/db/migrate/20160728103734_add_pipeline_events_to_services.rb @@ -7,7 +7,7 @@ class AddPipelineEventsToServices < ActiveRecord::Migration[4.2] def up add_column_with_default(:services, :pipeline_events, :boolean, - default: false, allow_null: false) + default: false, allow_null: false) end def down diff --git a/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb b/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb index 02e417e376f..29a687117d5 100644 --- a/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb +++ b/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb @@ -11,7 +11,7 @@ class RemoveProjectIdFromSpamLogs < ActiveRecord::Migration[4.2] # When a migration requires downtime you **must** uncomment the following # constant and define a short and easy to understand explanation as to why the # migration requires downtime. - DOWNTIME_REASON = 'Removing a column that contains data that is not used anywhere.' + DOWNTIME_REASON = "Removing a column that contains data that is not used anywhere." # When using the methods "add_concurrent_index" or "add_column_with_default" # you must disable the use of transactions as these methods can not run in an diff --git a/db/migrate/20160810102349_remove_ci_runner_trigram_indexes.rb b/db/migrate/20160810102349_remove_ci_runner_trigram_indexes.rb index 738b93912b6..11a496bb8cd 100644 --- a/db/migrate/20160810102349_remove_ci_runner_trigram_indexes.rb +++ b/db/migrate/20160810102349_remove_ci_runner_trigram_indexes.rb @@ -13,15 +13,15 @@ class RemoveCiRunnerTrigramIndexes < ActiveRecord::Migration[4.2] return unless Gitlab::Database.postgresql? transaction do - execute 'DROP INDEX IF EXISTS index_ci_runners_on_token_trigram;' - execute 'DROP INDEX IF EXISTS index_ci_runners_on_description_trigram;' + execute "DROP INDEX IF EXISTS index_ci_runners_on_token_trigram;" + execute "DROP INDEX IF EXISTS index_ci_runners_on_description_trigram;" end end def down return unless Gitlab::Database.postgresql? - execute 'CREATE INDEX CONCURRENTLY index_ci_runners_on_token_trigram ON ci_runners USING gin(token gin_trgm_ops);' - execute 'CREATE INDEX CONCURRENTLY index_ci_runners_on_description_trigram ON ci_runners USING gin(description gin_trgm_ops);' + execute "CREATE INDEX CONCURRENTLY index_ci_runners_on_token_trigram ON ci_runners USING gin(token gin_trgm_ops);" + execute "CREATE INDEX CONCURRENTLY index_ci_runners_on_description_trigram ON ci_runners USING gin(description gin_trgm_ops);" end end diff --git a/db/migrate/20160810142633_remove_redundant_indexes.rb b/db/migrate/20160810142633_remove_redundant_indexes.rb index 91f82cf9afa..5ad3f584cf7 100644 --- a/db/migrate/20160810142633_remove_redundant_indexes.rb +++ b/db/migrate/20160810142633_remove_redundant_indexes.rb @@ -11,51 +11,51 @@ class RemoveRedundantIndexes < ActiveRecord::Migration[4.2] def up indexes = [ - [:ci_taggings, 'ci_taggings_idx'], - [:audit_events, 'index_audit_events_on_author_id'], - [:audit_events, 'index_audit_events_on_type'], - [:ci_builds, 'index_ci_builds_on_erased_by_id'], - [:ci_builds, 'index_ci_builds_on_project_id_and_commit_id'], - [:ci_builds, 'index_ci_builds_on_type'], - [:ci_commits, 'index_ci_commits_on_project_id'], - [:ci_commits, 'index_ci_commits_on_project_id_and_committed_at'], - [:ci_commits, 'index_ci_commits_on_project_id_and_committed_at_and_id'], - [:ci_commits, 'index_ci_commits_on_project_id_and_sha'], - [:ci_commits, 'index_ci_commits_on_sha'], - [:ci_events, 'index_ci_events_on_created_at'], - [:ci_events, 'index_ci_events_on_is_admin'], - [:ci_events, 'index_ci_events_on_project_id'], - [:ci_jobs, 'index_ci_jobs_on_deleted_at'], - [:ci_jobs, 'index_ci_jobs_on_project_id'], - [:ci_projects, 'index_ci_projects_on_gitlab_id'], - [:ci_projects, 'index_ci_projects_on_shared_runners_enabled'], - [:ci_services, 'index_ci_services_on_project_id'], - [:ci_sessions, 'index_ci_sessions_on_session_id'], - [:ci_sessions, 'index_ci_sessions_on_updated_at'], - [:ci_tags, 'index_ci_tags_on_name'], - [:ci_triggers, 'index_ci_triggers_on_deleted_at'], - [:identities, 'index_identities_on_created_at_and_id'], - [:issues, 'index_issues_on_title'], - [:keys, 'index_keys_on_created_at_and_id'], - [:members, 'index_members_on_created_at_and_id'], - [:members, 'index_members_on_type'], - [:milestones, 'index_milestones_on_created_at_and_id'], - [:namespaces, 'index_namespaces_on_visibility_level'], - [:projects, 'index_projects_on_builds_enabled_and_shared_runners_enabled'], - [:services, 'index_services_on_category'], - [:services, 'index_services_on_created_at_and_id'], - [:services, 'index_services_on_default'], - [:snippets, 'index_snippets_on_created_at'], - [:snippets, 'index_snippets_on_created_at_and_id'], - [:todos, 'index_todos_on_state'], - [:web_hooks, 'index_web_hooks_on_created_at_and_id'], + [:ci_taggings, "ci_taggings_idx"], + [:audit_events, "index_audit_events_on_author_id"], + [:audit_events, "index_audit_events_on_type"], + [:ci_builds, "index_ci_builds_on_erased_by_id"], + [:ci_builds, "index_ci_builds_on_project_id_and_commit_id"], + [:ci_builds, "index_ci_builds_on_type"], + [:ci_commits, "index_ci_commits_on_project_id"], + [:ci_commits, "index_ci_commits_on_project_id_and_committed_at"], + [:ci_commits, "index_ci_commits_on_project_id_and_committed_at_and_id"], + [:ci_commits, "index_ci_commits_on_project_id_and_sha"], + [:ci_commits, "index_ci_commits_on_sha"], + [:ci_events, "index_ci_events_on_created_at"], + [:ci_events, "index_ci_events_on_is_admin"], + [:ci_events, "index_ci_events_on_project_id"], + [:ci_jobs, "index_ci_jobs_on_deleted_at"], + [:ci_jobs, "index_ci_jobs_on_project_id"], + [:ci_projects, "index_ci_projects_on_gitlab_id"], + [:ci_projects, "index_ci_projects_on_shared_runners_enabled"], + [:ci_services, "index_ci_services_on_project_id"], + [:ci_sessions, "index_ci_sessions_on_session_id"], + [:ci_sessions, "index_ci_sessions_on_updated_at"], + [:ci_tags, "index_ci_tags_on_name"], + [:ci_triggers, "index_ci_triggers_on_deleted_at"], + [:identities, "index_identities_on_created_at_and_id"], + [:issues, "index_issues_on_title"], + [:keys, "index_keys_on_created_at_and_id"], + [:members, "index_members_on_created_at_and_id"], + [:members, "index_members_on_type"], + [:milestones, "index_milestones_on_created_at_and_id"], + [:namespaces, "index_namespaces_on_visibility_level"], + [:projects, "index_projects_on_builds_enabled_and_shared_runners_enabled"], + [:services, "index_services_on_category"], + [:services, "index_services_on_created_at_and_id"], + [:services, "index_services_on_default"], + [:snippets, "index_snippets_on_created_at"], + [:snippets, "index_snippets_on_created_at_and_id"], + [:todos, "index_todos_on_state"], + [:web_hooks, "index_web_hooks_on_created_at_and_id"], # These indexes _may_ be used but they can be replaced by other existing # indexes. # There's already a composite index on (project_id, iid) which means that # a separate index for _just_ project_id is not needed. - [:issues, 'index_issues_on_project_id'], + [:issues, "index_issues_on_project_id"], # These are all composite indexes for the columns (created_at, id). In all # these cases there's already a standalone index for "created_at" which @@ -64,12 +64,12 @@ class RemoveRedundantIndexes < ActiveRecord::Migration[4.2] # Because the "id" column of these composite indexes is never needed (due # to "id" already being indexed as its a primary key) these composite # indexes are useless. - [:issues, 'index_issues_on_created_at_and_id'], - [:merge_requests, 'index_merge_requests_on_created_at_and_id'], - [:namespaces, 'index_namespaces_on_created_at_and_id'], - [:notes, 'index_notes_on_created_at_and_id'], - [:projects, 'index_projects_on_created_at_and_id'], - [:users, 'index_users_on_created_at_and_id'] + [:issues, "index_issues_on_created_at_and_id"], + [:merge_requests, "index_merge_requests_on_created_at_and_id"], + [:namespaces, "index_namespaces_on_created_at_and_id"], + [:notes, "index_notes_on_created_at_and_id"], + [:projects, "index_projects_on_created_at_and_id"], + [:users, "index_users_on_created_at_and_id"], ] transaction do @@ -94,7 +94,7 @@ class RemoveRedundantIndexes < ActiveRecord::Migration[4.2] [:issues, :merge_requests, :namespaces, :notes, :projects, :users].each do |table| add_concurrent_index(table, [:created_at, :id], - name: "index_#{table}_on_created_at_and_id") + name: "index_#{table}_on_created_at_and_id") end end @@ -106,8 +106,8 @@ class RemoveRedundantIndexes < ActiveRecord::Migration[4.2] end def indexes_for_table - @indexes_for_table ||= Hash.new do |hash, table_name| + @indexes_for_table ||= Hash.new { |hash, table_name| hash[table_name] = indexes(table_name).map(&:name) - end + } end end diff --git a/db/migrate/20160823081327_change_merge_error_to_text.rb b/db/migrate/20160823081327_change_merge_error_to_text.rb index 23b4f35a776..158205d9d06 100644 --- a/db/migrate/20160823081327_change_merge_error_to_text.rb +++ b/db/migrate/20160823081327_change_merge_error_to_text.rb @@ -2,7 +2,7 @@ class ChangeMergeErrorToText < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration requires downtime because it alters a column from varchar(255) to text.' + DOWNTIME_REASON = "This migration requires downtime because it alters a column from varchar(255) to text." def change change_column :merge_requests, :merge_error, :text, limit: 65535 diff --git a/db/migrate/20160823083941_add_column_scopes_to_personal_access_tokens.rb b/db/migrate/20160823083941_add_column_scopes_to_personal_access_tokens.rb index 4c320123088..6fb6abfa395 100644 --- a/db/migrate/20160823083941_add_column_scopes_to_personal_access_tokens.rb +++ b/db/migrate/20160823083941_add_column_scopes_to_personal_access_tokens.rb @@ -10,7 +10,7 @@ class AddColumnScopesToPersonalAccessTokens < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - add_column_with_default :personal_access_tokens, :scopes, :string, default: ['api'].to_yaml + add_column_with_default :personal_access_tokens, :scopes, :string, default: ["api"].to_yaml end def down diff --git a/db/migrate/20160824124900_add_table_issue_metrics.rb b/db/migrate/20160824124900_add_table_issue_metrics.rb index 4f34f377e22..86e0334ddba 100644 --- a/db/migrate/20160824124900_add_table_issue_metrics.rb +++ b/db/migrate/20160824124900_add_table_issue_metrics.rb @@ -10,7 +10,7 @@ class AddTableIssueMetrics < ActiveRecord::Migration[4.2] # When a migration requires downtime you **must** uncomment the following # constant and define a short and easy to understand explanation as to why the # migration requires downtime. - DOWNTIME_REASON = 'Adding foreign key' + DOWNTIME_REASON = "Adding foreign key" # When using the methods "add_concurrent_index" or "add_column_with_default" # you must disable the use of transactions as these methods can not run in an @@ -25,11 +25,11 @@ class AddTableIssueMetrics < ActiveRecord::Migration[4.2] def change create_table :issue_metrics do |t| - t.references :issue, index: { name: "index_issue_metrics" }, foreign_key: { on_delete: :cascade }, null: false + t.references :issue, index: {name: "index_issue_metrics"}, foreign_key: {on_delete: :cascade}, null: false - t.datetime 'first_mentioned_in_commit_at' - t.datetime 'first_associated_with_milestone_at' - t.datetime 'first_added_to_board_at' + t.datetime "first_mentioned_in_commit_at" + t.datetime "first_associated_with_milestone_at" + t.datetime "first_added_to_board_at" t.timestamps null: false end diff --git a/db/migrate/20160825052008_add_table_merge_request_metrics.rb b/db/migrate/20160825052008_add_table_merge_request_metrics.rb index 150f698869d..06e56a7fbb3 100644 --- a/db/migrate/20160825052008_add_table_merge_request_metrics.rb +++ b/db/migrate/20160825052008_add_table_merge_request_metrics.rb @@ -10,7 +10,7 @@ class AddTableMergeRequestMetrics < ActiveRecord::Migration[4.2] # When a migration requires downtime you **must** uncomment the following # constant and define a short and easy to understand explanation as to why the # migration requires downtime. - DOWNTIME_REASON = 'Adding foreign key' + DOWNTIME_REASON = "Adding foreign key" # When using the methods "add_concurrent_index" or "add_column_with_default" # you must disable the use of transactions as these methods can not run in an @@ -25,12 +25,12 @@ class AddTableMergeRequestMetrics < ActiveRecord::Migration[4.2] def change create_table :merge_request_metrics do |t| - t.references :merge_request, index: { name: "index_merge_request_metrics" }, foreign_key: { on_delete: :cascade }, null: false + t.references :merge_request, index: {name: "index_merge_request_metrics"}, foreign_key: {on_delete: :cascade}, null: false - t.datetime 'latest_build_started_at' - t.datetime 'latest_build_finished_at' - t.datetime 'first_deployed_to_production_at', index: true - t.datetime 'merged_at' + t.datetime "latest_build_started_at" + t.datetime "latest_build_finished_at" + t.datetime "first_deployed_to_production_at", index: true + t.datetime "merged_at" t.timestamps null: false end diff --git a/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb b/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb index 18c0f0be3eb..01f2c3dc7f2 100644 --- a/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb +++ b/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb @@ -7,8 +7,8 @@ class EnsureLockVersionHasNoDefault < ActiveRecord::Migration[4.2] change_column_default :issues, :lock_version, nil change_column_default :merge_requests, :lock_version, nil - execute('UPDATE issues SET lock_version = 1 WHERE lock_version = 0') - execute('UPDATE merge_requests SET lock_version = 1 WHERE lock_version = 0') + execute("UPDATE issues SET lock_version = 1 WHERE lock_version = 0") + execute("UPDATE merge_requests SET lock_version = 1 WHERE lock_version = 0") end def down diff --git a/db/migrate/20160829114652_add_markdown_cache_columns.rb b/db/migrate/20160829114652_add_markdown_cache_columns.rb index b1c5e38c3c4..a4ac9eca16f 100644 --- a/db/migrate/20160829114652_add_markdown_cache_columns.rb +++ b/db/migrate/20160829114652_add_markdown_cache_columns.rb @@ -14,7 +14,7 @@ class AddMarkdownCacheColumns < ActiveRecord::Migration[4.2] :sign_in_text, :help_page_text, :shared_runners_text, - :after_sign_up_text + :after_sign_up_text, ], broadcast_messages: [:message], issues: [:title, :description], @@ -25,7 +25,7 @@ class AddMarkdownCacheColumns < ActiveRecord::Migration[4.2] notes: [:note], projects: [:description], releases: [:description], - snippets: [:title, :content] + snippets: [:title, :content], }.freeze def change diff --git a/db/migrate/20160831214543_migrate_project_features.rb b/db/migrate/20160831214543_migrate_project_features.rb index ba7ffd7c9f2..a5f686d8c26 100644 --- a/db/migrate/20160831214543_migrate_project_features.rb +++ b/db/migrate/20160831214543_migrate_project_features.rb @@ -10,7 +10,7 @@ class MigrateProjectFeatures < ActiveRecord::Migration[4.2] def up sql = - %Q{ + %{ INSERT INTO project_features(project_id, issues_access_level, merge_requests_access_level, wiki_access_level, builds_access_level, snippets_access_level, created_at, updated_at) SELECT @@ -29,7 +29,7 @@ class MigrateProjectFeatures < ActiveRecord::Migration[4.2] end def down - sql = %Q{ + sql = %{ UPDATE projects SET issues_enabled = COALESCE((SELECT CASE WHEN issues_access_level = 20 THEN true ELSE false END AS issues_enabled FROM project_features WHERE project_features.project_id = projects.id), true), diff --git a/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb b/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb index 6c2dc58876e..754207f388f 100644 --- a/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb +++ b/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb @@ -5,19 +5,19 @@ class DropGitoriousFieldFromApplicationSettings < ActiveRecord::Migration[4.2] DOWNTIME = false def up - require 'yaml' + require "yaml" - import_sources = connection.execute('SELECT import_sources FROM application_settings;') + import_sources = connection.execute("SELECT import_sources FROM application_settings;") return unless import_sources.first # support empty databases yaml = if Gitlab::Database.postgresql? - import_sources.values[0][0] - else - import_sources.first[0] - end + import_sources.values[0][0] + else + import_sources.first[0] + end yaml = YAML.safe_load(yaml) - yaml.delete 'gitorious' + yaml.delete "gitorious" # No need for a WHERE clause as there is only one connection.execute("UPDATE application_settings SET import_sources = #{update_yaml(yaml)}") diff --git a/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb b/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb index 51650c68170..bfab62f83c9 100644 --- a/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb +++ b/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb @@ -7,7 +7,7 @@ class RemoveProjectsPushesSinceGc < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration removes an existing column' + DOWNTIME_REASON = "This migration removes an existing column" disable_ddl_transaction! diff --git a/db/migrate/20160913212128_change_artifacts_size_column.rb b/db/migrate/20160913212128_change_artifacts_size_column.rb index f2c2aaff9a8..f2017fc07da 100644 --- a/db/migrate/20160913212128_change_artifacts_size_column.rb +++ b/db/migrate/20160913212128_change_artifacts_size_column.rb @@ -3,7 +3,7 @@ class ChangeArtifactsSizeColumn < ActiveRecord::Migration[4.2] DOWNTIME = true - DOWNTIME_REASON = 'Changing an integer column size requires a full table rewrite.' + DOWNTIME_REASON = "Changing an integer column size requires a full table rewrite." def up change_column :ci_builds, :artifacts_size, :integer, limit: 8 diff --git a/db/migrate/20160915042921_create_merge_requests_closing_issues.rb b/db/migrate/20160915042921_create_merge_requests_closing_issues.rb index 3efe8c8901b..dc405b25054 100644 --- a/db/migrate/20160915042921_create_merge_requests_closing_issues.rb +++ b/db/migrate/20160915042921_create_merge_requests_closing_issues.rb @@ -11,7 +11,7 @@ class CreateMergeRequestsClosingIssues < ActiveRecord::Migration[4.2] # When a migration requires downtime you **must** uncomment the following # constant and define a short and easy to understand explanation as to why the # migration requires downtime. - DOWNTIME_REASON = 'Adding foreign keys' + DOWNTIME_REASON = "Adding foreign keys" # When using the methods "add_concurrent_index" or "add_column_with_default" # you must disable the use of transactions as these methods can not run in an @@ -26,8 +26,8 @@ class CreateMergeRequestsClosingIssues < ActiveRecord::Migration[4.2] def change create_table :merge_requests_closing_issues do |t| - t.references :merge_request, foreign_key: { on_delete: :cascade }, index: true, null: false - t.references :issue, foreign_key: { on_delete: :cascade }, index: true, null: false + t.references :merge_request, foreign_key: {on_delete: :cascade}, index: true, null: false + t.references :issue, foreign_key: {on_delete: :cascade}, index: true, null: false t.timestamps null: false end diff --git a/db/migrate/20160919144305_add_type_to_labels.rb b/db/migrate/20160919144305_add_type_to_labels.rb index f897646d264..ab959032a41 100644 --- a/db/migrate/20160919144305_add_type_to_labels.rb +++ b/db/migrate/20160919144305_add_type_to_labels.rb @@ -3,14 +3,14 @@ class AddTypeToLabels < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Labels will not work as expected until this migration is complete.' + DOWNTIME_REASON = "Labels will not work as expected until this migration is complete." disable_ddl_transaction! def change add_column :labels, :type, :string - update_column_in_batches(:labels, :type, 'ProjectLabel') do |table, query| + update_column_in_batches(:labels, :type, "ProjectLabel") do |table, query| query.where(table[:project_id].not_eq(nil)) end end diff --git a/db/migrate/20161007133303_precalculate_trending_projects.rb b/db/migrate/20161007133303_precalculate_trending_projects.rb index c7a678c9d8f..0131d1be403 100644 --- a/db/migrate/20161007133303_precalculate_trending_projects.rb +++ b/db/migrate/20161007133303_precalculate_trending_projects.rb @@ -8,7 +8,7 @@ class PrecalculateTrendingProjects < ActiveRecord::Migration[4.2] def up create_table :trending_projects do |t| - t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false + t.references :project, index: true, foreign_key: {on_delete: :cascade}, null: false end timestamp = connection.quote(1.month.ago) diff --git a/db/migrate/20161010142410_create_project_authorizations.rb b/db/migrate/20161010142410_create_project_authorizations.rb index b340a4ece19..7f3b42a9e41 100644 --- a/db/migrate/20161010142410_create_project_authorizations.rb +++ b/db/migrate/20161010142410_create_project_authorizations.rb @@ -5,11 +5,11 @@ class CreateProjectAuthorizations < ActiveRecord::Migration[4.2] def change create_table :project_authorizations do |t| - t.references :user, foreign_key: { on_delete: :cascade } - t.references :project, foreign_key: { on_delete: :cascade } + t.references :user, foreign_key: {on_delete: :cascade} + t.references :project, foreign_key: {on_delete: :cascade} t.integer :access_level - t.index [:user_id, :project_id, :access_level], unique: true, name: 'index_project_authorizations_on_user_id_project_id_access_level' + t.index [:user_id, :project_id, :access_level], unique: true, name: "index_project_authorizations_on_user_id_project_id_access_level" end end end diff --git a/db/migrate/20161014173530_create_label_priorities.rb b/db/migrate/20161014173530_create_label_priorities.rb index c7d60caa7d1..e37785e583c 100644 --- a/db/migrate/20161014173530_create_label_priorities.rb +++ b/db/migrate/20161014173530_create_label_priorities.rb @@ -3,14 +3,14 @@ class CreateLabelPriorities < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration adds foreign keys' + DOWNTIME_REASON = "This migration adds foreign keys" disable_ddl_transaction! def up create_table :label_priorities do |t| - t.references :project, foreign_key: { on_delete: :cascade }, null: false - t.references :label, foreign_key: { on_delete: :cascade }, null: false + t.references :project, foreign_key: {on_delete: :cascade}, null: false + t.references :label, foreign_key: {on_delete: :cascade}, null: false t.integer :priority, null: false t.timestamps null: false diff --git a/db/migrate/20161017125927_add_unique_index_to_labels.rb b/db/migrate/20161017125927_add_unique_index_to_labels.rb index b5326789f52..c1e612058f7 100644 --- a/db/migrate/20161017125927_add_unique_index_to_labels.rb +++ b/db/migrate/20161017125927_add_unique_index_to_labels.rb @@ -3,14 +3,14 @@ class AddUniqueIndexToLabels < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration removes duplicated labels.' + DOWNTIME_REASON = "This migration removes duplicated labels." disable_ddl_transaction! def up - select_all('SELECT title, project_id, COUNT(id) as cnt FROM labels GROUP BY project_id, title HAVING COUNT(id) > 1').each do |label| - label_title = quote_string(label['title']) - duplicated_ids = select_all("SELECT id FROM labels WHERE project_id = #{label['project_id']} AND title = '#{label_title}' ORDER BY id ASC").map { |label| label['id'] } + select_all("SELECT title, project_id, COUNT(id) as cnt FROM labels GROUP BY project_id, title HAVING COUNT(id) > 1").each do |label| + label_title = quote_string(label["title"]) + duplicated_ids = select_all("SELECT id FROM labels WHERE project_id = #{label["project_id"]} AND title = '#{label_title}' ORDER BY id ASC").map { |label| label["id"] } label_id = duplicated_ids.first duplicated_ids.delete(label_id) diff --git a/db/migrate/20161018024215_migrate_labels_priority.rb b/db/migrate/20161018024215_migrate_labels_priority.rb index 3e2540c134c..25baadcaa0c 100644 --- a/db/migrate/20161018024215_migrate_labels_priority.rb +++ b/db/migrate/20161018024215_migrate_labels_priority.rb @@ -2,7 +2,7 @@ class MigrateLabelsPriority < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Prioritized labels will not work as expected until this migration is complete.' + DOWNTIME_REASON = "Prioritized labels will not work as expected until this migration is complete." disable_ddl_transaction! diff --git a/db/migrate/20161018024550_remove_priority_from_labels.rb b/db/migrate/20161018024550_remove_priority_from_labels.rb index e164d959bdf..e760abee85d 100644 --- a/db/migrate/20161018024550_remove_priority_from_labels.rb +++ b/db/migrate/20161018024550_remove_priority_from_labels.rb @@ -3,7 +3,7 @@ class RemovePriorityFromLabels < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration removes an existing column' + DOWNTIME_REASON = "This migration removes an existing column" disable_ddl_transaction! diff --git a/db/migrate/20161018124658_make_project_owners_masters.rb b/db/migrate/20161018124658_make_project_owners_masters.rb index 132c17388dc..b33aeaed498 100644 --- a/db/migrate/20161018124658_make_project_owners_masters.rb +++ b/db/migrate/20161018124658_make_project_owners_masters.rb @@ -8,7 +8,7 @@ class MakeProjectOwnersMasters < ActiveRecord::Migration[4.2] def up update_column_in_batches(:members, :access_level, 40) do |table, query| - query.where(table[:access_level].eq(50).and(table[:source_type].eq('Project'))) + query.where(table[:access_level].eq(50).and(table[:source_type].eq("Project"))) end end diff --git a/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb b/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb index fc6d9784638..089ad660b0f 100644 --- a/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb +++ b/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb @@ -1,4 +1,4 @@ -require 'json' +require "json" # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. @@ -23,54 +23,54 @@ class MigrateSidekiqQueuesFromDefault < ActiveRecord::Migration[4.2] # queue names. RENAMED_QUEUES = { gitlab_shell: { - 'GitGarbageCollectorWorker' => :git_garbage_collector, - 'ProjectExportWorker' => :project_export, - 'RepositoryForkWorker' => :repository_fork, - 'RepositoryImportWorker' => :repository_import + "GitGarbageCollectorWorker" => :git_garbage_collector, + "ProjectExportWorker" => :project_export, + "RepositoryForkWorker" => :repository_fork, + "RepositoryImportWorker" => :repository_import, }, project_web_hook: { - 'ProjectServiceWorker' => :project_service + "ProjectServiceWorker" => :project_service, }, incoming_email: { - 'EmailReceiverWorker' => :email_receiver + "EmailReceiverWorker" => :email_receiver, }, mailers: { - 'EmailsOnPushWorker' => :emails_on_push + "EmailsOnPushWorker" => :emails_on_push, }, default: { - 'AdminEmailWorker' => :cronjob, - 'BuildCoverageWorker' => :build, - 'BuildEmailWorker' => :build, - 'BuildFinishedWorker' => :build, - 'BuildHooksWorker' => :build, - 'BuildSuccessWorker' => :build, - 'ClearDatabaseCacheWorker' => :clear_database_cache, - 'DeleteUserWorker' => :delete_user, - 'ExpireBuildArtifactsWorker' => :cronjob, - 'ExpireBuildInstanceArtifactsWorker' => :expire_build_instance_artifacts, - 'GroupDestroyWorker' => :group_destroy, - 'ImportExportProjectCleanupWorker' => :cronjob, - 'IrkerWorker' => :irker, - 'MergeWorker' => :merge, - 'NewNoteWorker' => :new_note, - 'PipelineHooksWorker' => :pipeline, - 'PipelineMetricsWorker' => :pipeline, - 'PipelineProcessWorker' => :pipeline, - 'PipelineSuccessWorker' => :pipeline, - 'PipelineUpdateWorker' => :pipeline, - 'ProjectCacheWorker' => :project_cache, - 'ProjectDestroyWorker' => :project_destroy, - 'PruneOldEventsWorker' => :cronjob, - 'RemoveExpiredGroupLinksWorker' => :cronjob, - 'RemoveExpiredMembersWorker' => :cronjob, - 'RepositoryArchiveCacheWorker' => :cronjob, - 'RepositoryCheck::BatchWorker' => :cronjob, - 'RepositoryCheck::ClearWorker' => :repository_check, - 'RepositoryCheck::SingleRepositoryWorker' => :repository_check, - 'RequestsProfilesWorker' => :cronjob, - 'StuckCiBuildsWorker' => :cronjob, - 'UpdateMergeRequestsWorker' => :update_merge_requests - } + "AdminEmailWorker" => :cronjob, + "BuildCoverageWorker" => :build, + "BuildEmailWorker" => :build, + "BuildFinishedWorker" => :build, + "BuildHooksWorker" => :build, + "BuildSuccessWorker" => :build, + "ClearDatabaseCacheWorker" => :clear_database_cache, + "DeleteUserWorker" => :delete_user, + "ExpireBuildArtifactsWorker" => :cronjob, + "ExpireBuildInstanceArtifactsWorker" => :expire_build_instance_artifacts, + "GroupDestroyWorker" => :group_destroy, + "ImportExportProjectCleanupWorker" => :cronjob, + "IrkerWorker" => :irker, + "MergeWorker" => :merge, + "NewNoteWorker" => :new_note, + "PipelineHooksWorker" => :pipeline, + "PipelineMetricsWorker" => :pipeline, + "PipelineProcessWorker" => :pipeline, + "PipelineSuccessWorker" => :pipeline, + "PipelineUpdateWorker" => :pipeline, + "ProjectCacheWorker" => :project_cache, + "ProjectDestroyWorker" => :project_destroy, + "PruneOldEventsWorker" => :cronjob, + "RemoveExpiredGroupLinksWorker" => :cronjob, + "RemoveExpiredMembersWorker" => :cronjob, + "RepositoryArchiveCacheWorker" => :cronjob, + "RepositoryCheck::BatchWorker" => :cronjob, + "RepositoryCheck::ClearWorker" => :repository_check, + "RepositoryCheck::SingleRepositoryWorker" => :repository_check, + "RequestsProfilesWorker" => :cronjob, + "StuckCiBuildsWorker" => :cronjob, + "UpdateMergeRequestsWorker" => :update_merge_requests, + }, }.freeze def up @@ -94,14 +94,14 @@ class MigrateSidekiqQueuesFromDefault < ActiveRecord::Migration[4.2] def migrate_from_queue(redis, queue, job_mapping) while job = redis.lpop("queue:#{queue}") payload = JSON.parse(job) - new_queue = job_mapping[payload['class']] + new_queue = job_mapping[payload["class"]] # If we have no target queue to migrate to we're probably dealing with # some ancient job for which the worker no longer exists. In that case # there's no sane option we can take, other than just dropping the job. next unless new_queue - payload['queue'] = new_queue + payload["queue"] = new_queue redis.lpush("queue:#{new_queue}", JSON.dump(payload)) end diff --git a/db/migrate/20161019213545_generate_project_feature_for_projects.rb b/db/migrate/20161019213545_generate_project_feature_for_projects.rb index 587bdf60f70..d30efec30f6 100644 --- a/db/migrate/20161019213545_generate_project_feature_for_projects.rb +++ b/db/migrate/20161019213545_generate_project_feature_for_projects.rb @@ -16,7 +16,7 @@ class GenerateProjectFeatureForProjects < ActiveRecord::Migration[4.2] INSERT INTO project_features (project_id, merge_requests_access_level, builds_access_level, issues_access_level, snippets_access_level, wiki_access_level) - (SELECT projects.id, #{enabled_values.join(',')} FROM projects LEFT OUTER JOIN project_features + (SELECT projects.id, #{enabled_values.join(",")} FROM projects LEFT OUTER JOIN project_features ON project_features.project_id = projects.id WHERE project_features.id IS NULL) EOF diff --git a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb index 60352363e42..34eb7d0747b 100644 --- a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb +++ b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb @@ -13,7 +13,7 @@ class AddPipelineIdToMergeRequestMetrics < ActiveRecord::Migration[4.2] # When a migration requires downtime you **must** uncomment the following # constant and define a short and easy to understand explanation as to why the # migration requires downtime. - DOWNTIME_REASON = 'Adding a foreign key' + DOWNTIME_REASON = "Adding a foreign key" # When using the methods "add_concurrent_index" or "add_column_with_default" # you must disable the use of transactions as these methods can not run in an diff --git a/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb b/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb index d27f8fc38c8..b1b4df2b628 100644 --- a/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb +++ b/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb @@ -1,4 +1,4 @@ -require 'json' +require "json" # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. @@ -22,9 +22,9 @@ class MigrateMailroomQueueFromDefault < ActiveRecord::Migration[4.2] # The keys are the old queue names, the values the jobs to move and their new # queue names. RENAMED_QUEUES = { - incoming_email: { - 'EmailReceiverWorker' => :email_receiver - } + incoming_email: { + "EmailReceiverWorker" => :email_receiver, + }, }.freeze def up @@ -48,14 +48,14 @@ class MigrateMailroomQueueFromDefault < ActiveRecord::Migration[4.2] def migrate_from_queue(redis, queue, job_mapping) while job = redis.lpop("queue:#{queue}") payload = JSON.parse(job) - new_queue = job_mapping[payload['class']] + new_queue = job_mapping[payload["class"]] # If we have no target queue to migrate to we're probably dealing with # some ancient job for which the worker no longer exists. In that case # there's no sane option we can take, other than just dropping the job. next unless new_queue - payload['queue'] = new_queue + payload["queue"] = new_queue redis.lpush("queue:#{new_queue}", JSON.dump(payload)) end diff --git a/db/migrate/20161025231710_migrate_jira_to_gem.rb b/db/migrate/20161025231710_migrate_jira_to_gem.rb index aa1c59ec9e6..b9e6e2ef4a4 100644 --- a/db/migrate/20161025231710_migrate_jira_to_gem.rb +++ b/db/migrate/20161025231710_migrate_jira_to_gem.rb @@ -13,28 +13,28 @@ class MigrateJiraToGem < ActiveRecord::Migration[4.2] active_services_query = "SELECT id, properties FROM services WHERE services.type IN ('JiraService') AND services.active = true" select_all(active_services_query).each do |service| - id = service['id'] - properties = JSON.parse(service['properties']) + id = service["id"] + properties = JSON.parse(service["properties"]) properties_was = properties.clone # Migrate `project_url` to `project_key` # Ignore if `project_url` doesn't have jql project query with project key - if properties['project_url'].present? - jql = properties['project_url'].match('project=([A-Za-z]*)') - properties['project_key'] = jql.captures.first if jql + if properties["project_url"].present? + jql = properties["project_url"].match("project=([A-Za-z]*)") + properties["project_key"] = jql.captures.first if jql end # Migrate `api_url` to `url` - if properties['api_url'].present? - url = properties['api_url'].match('(.*)\/rest\/api') - properties['url'] = url.captures.first if url + if properties["api_url"].present? + url = properties["api_url"].match('(.*)\/rest\/api') + properties["url"] = url.captures.first if url end # Delete now unnecessary properties - properties.delete('api_url') - properties.delete('project_url') - properties.delete('new_issue_url') - properties.delete('issues_url') + properties.delete("api_url") + properties.delete("project_url") + properties.delete("new_issue_url") + properties.delete("issues_url") # Update changes properties if properties != properties_was @@ -47,22 +47,22 @@ class MigrateJiraToGem < ActiveRecord::Migration[4.2] active_services_query = "SELECT id, properties FROM services WHERE services.type IN ('JiraService') AND services.active = true" select_all(active_services_query).each do |service| - id = service['id'] - properties = JSON.parse(service['properties']) + id = service["id"] + properties = JSON.parse(service["properties"]) properties_was = properties.clone # Rebuild old properties based on sane defaults - if properties['url'].present? - properties['api_url'] = "#{properties['url']}/rest/api/2" - properties['project_url'] = - "#{properties['url']}/issues/?jql=project=#{properties['project_key']}" - properties['issues_url'] = "#{properties['url']}/browse/:id" - properties['new_issue_url'] = "#{properties['url']}/secure/CreateIssue.jspa" + if properties["url"].present? + properties["api_url"] = "#{properties["url"]}/rest/api/2" + properties["project_url"] = + "#{properties["url"]}/issues/?jql=project=#{properties["project_key"]}" + properties["issues_url"] = "#{properties["url"]}/browse/:id" + properties["new_issue_url"] = "#{properties["url"]}/secure/CreateIssue.jspa" end # Delete the new properties - properties.delete('url') - properties.delete('project_key') + properties.delete("url") + properties.delete("project_key") # Update changes properties if properties != properties_was diff --git a/db/migrate/20161031174110_migrate_subscriptions_project_id.rb b/db/migrate/20161031174110_migrate_subscriptions_project_id.rb index 7f4087fdcd3..47826b0ab6b 100644 --- a/db/migrate/20161031174110_migrate_subscriptions_project_id.rb +++ b/db/migrate/20161031174110_migrate_subscriptions_project_id.rb @@ -2,7 +2,7 @@ class MigrateSubscriptionsProjectId < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Subscriptions will not work as expected until this migration is complete.' + DOWNTIME_REASON = "Subscriptions will not work as expected until this migration is complete." def up execute <<-EOF.strip_heredoc diff --git a/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb b/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb index 23a775d6282..e6dab8e8691 100644 --- a/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb +++ b/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb @@ -3,17 +3,17 @@ class AddUniqueIndexToSubscriptions < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration requires downtime because it changes a column to not accept null values.' + DOWNTIME_REASON = "This migration requires downtime because it changes a column to not accept null values." disable_ddl_transaction! def up - add_concurrent_index :subscriptions, [:subscribable_id, :subscribable_type, :user_id, :project_id], { unique: true, name: 'index_subscriptions_on_subscribable_and_user_id_and_project_id' } - remove_index :subscriptions, name: 'subscriptions_user_id_and_ref_fields' if index_name_exists?(:subscriptions, 'subscriptions_user_id_and_ref_fields', false) + add_concurrent_index :subscriptions, [:subscribable_id, :subscribable_type, :user_id, :project_id], {unique: true, name: "index_subscriptions_on_subscribable_and_user_id_and_project_id"} + remove_index :subscriptions, name: "subscriptions_user_id_and_ref_fields" if index_name_exists?(:subscriptions, "subscriptions_user_id_and_ref_fields", false) end def down - add_concurrent_index :subscriptions, [:subscribable_id, :subscribable_type, :user_id], { unique: true, name: 'subscriptions_user_id_and_ref_fields' } - remove_index :subscriptions, name: 'index_subscriptions_on_subscribable_and_user_id_and_project_id' if index_name_exists?(:subscriptions, 'index_subscriptions_on_subscribable_and_user_id_and_project_id', false) + add_concurrent_index :subscriptions, [:subscribable_id, :subscribable_type, :user_id], {unique: true, name: "subscriptions_user_id_and_ref_fields"} + remove_index :subscriptions, name: "index_subscriptions_on_subscribable_and_user_id_and_project_id" if index_name_exists?(:subscriptions, "index_subscriptions_on_subscribable_and_user_id_and_project_id", false) end end diff --git a/db/migrate/20161103171205_rename_repository_storage_column.rb b/db/migrate/20161103171205_rename_repository_storage_column.rb index d6050500e47..58cb954325e 100644 --- a/db/migrate/20161103171205_rename_repository_storage_column.rb +++ b/db/migrate/20161103171205_rename_repository_storage_column.rb @@ -10,7 +10,7 @@ class RenameRepositoryStorageColumn < ActiveRecord::Migration[4.2] # When a migration requires downtime you **must** uncomment the following # constant and define a short and easy to understand explanation as to why the # migration requires downtime. - DOWNTIME_REASON = 'Renaming the application_settings.repository_storage column' + DOWNTIME_REASON = "Renaming the application_settings.repository_storage column" # When using the methods "add_concurrent_index" or "add_column_with_default" # you must disable the use of transactions as these methods can not run in an diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb index 0772821210c..c5620a57508 100644 --- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb +++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb @@ -17,7 +17,7 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration[4.2] class Project < ActiveRecord::Base def self.find_including_path(id) select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace") - .joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id') + .joins("INNER JOIN namespaces ON namespaces.id = projects.namespace_id") .find_by(id: id) end @@ -26,12 +26,12 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration[4.2] end def repository - @repository ||= Repository.new(repository_storage, read_attribute(:path_with_namespace) + '.git') + @repository ||= Repository.new(repository_storage, read_attribute(:path_with_namespace) + ".git") end end DOWNTIME = true - DOWNTIME_REASON = 'Existing workers will error until they are using a newer version of the code' + DOWNTIME_REASON = "Existing workers will error until they are using a newer version of the code" disable_ddl_transaction! @@ -39,13 +39,13 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration[4.2] Sidekiq.redis do |redis| new_jobs = [] - while job = redis.lpop('queue:process_commit') + while job = redis.lpop("queue:process_commit") payload = JSON.parse(job) - project = Project.find_including_path(payload['args'][0]) + project = Project.find_including_path(payload["args"][0]) next unless project - commit = project.commit(payload['args'][2]) + commit = project.commit(payload["args"][2]) next unless commit hash = { @@ -57,17 +57,17 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration[4.2] author_email: encode(commit.author.email), committed_date: Time.at(commit.committer.date.seconds).utc, committer_email: encode(commit.committer.email), - committer_name: encode(commit.committer.name) + committer_name: encode(commit.committer.name), } - payload['args'][2] = hash + payload["args"][2] = hash new_jobs << JSON.dump(payload) end redis.multi do |multi| new_jobs.each do |j| - multi.lpush('queue:process_commit', j) + multi.lpush("queue:process_commit", j) end end end @@ -77,17 +77,17 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration[4.2] Sidekiq.redis do |redis| new_jobs = [] - while job = redis.lpop('queue:process_commit') + while job = redis.lpop("queue:process_commit") payload = JSON.parse(job) - payload['args'][2] = payload['args'][2]['id'] + payload["args"][2] = payload["args"][2]["id"] new_jobs << JSON.dump(payload) end redis.multi do |multi| new_jobs.each do |j| - multi.lpush('queue:process_commit', j) + multi.lpush("queue:process_commit", j) end end end diff --git a/db/migrate/20161128142110_remove_unnecessary_indexes.rb b/db/migrate/20161128142110_remove_unnecessary_indexes.rb index b6c6e303ec7..50124dac5c0 100644 --- a/db/migrate/20161128142110_remove_unnecessary_indexes.rb +++ b/db/migrate/20161128142110_remove_unnecessary_indexes.rb @@ -13,7 +13,7 @@ class RemoveUnnecessaryIndexes < ActiveRecord::Migration[4.2] remove_index :award_emoji, column: :user_id if index_exists?(:award_emoji, :user_id) remove_index :ci_builds, column: :commit_id if index_exists?(:ci_builds, :commit_id) remove_index :deployments, column: :project_id if index_exists?(:deployments, :project_id) - remove_index :deployments, column: %w(project_id environment_id) if index_exists?(:deployments, %w(project_id environment_id)) + remove_index :deployments, column: %w[project_id environment_id] if index_exists?(:deployments, %w[project_id environment_id]) remove_index :lists, column: :board_id if index_exists?(:lists, :board_id) remove_index :milestones, column: :project_id if index_exists?(:milestones, :project_id) remove_index :notes, column: :project_id if index_exists?(:notes, :project_id) @@ -25,7 +25,7 @@ class RemoveUnnecessaryIndexes < ActiveRecord::Migration[4.2] add_concurrent_index :award_emoji, :user_id add_concurrent_index :ci_builds, :commit_id add_concurrent_index :deployments, :project_id - add_concurrent_index :deployments, %w(project_id environment_id) + add_concurrent_index :deployments, %w[project_id environment_id] add_concurrent_index :lists, :board_id add_concurrent_index :milestones, :project_id add_concurrent_index :notes, :project_id diff --git a/db/migrate/20161130095245_fill_routes_table.rb b/db/migrate/20161130095245_fill_routes_table.rb index 712be187c7c..6bbb2b44ea9 100644 --- a/db/migrate/20161130095245_fill_routes_table.rb +++ b/db/migrate/20161130095245_fill_routes_table.rb @@ -5,7 +5,7 @@ class FillRoutesTable < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'No new namespaces should be created during data copy' + DOWNTIME_REASON = "No new namespaces should be created during data copy" def up execute <<-EOF diff --git a/db/migrate/20161130101252_fill_projects_routes_table.rb b/db/migrate/20161130101252_fill_projects_routes_table.rb index 1900d6c8013..9a8399f5936 100644 --- a/db/migrate/20161130101252_fill_projects_routes_table.rb +++ b/db/migrate/20161130101252_fill_projects_routes_table.rb @@ -5,7 +5,7 @@ class FillProjectsRoutesTable < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'No new projects should be created during data copy' + DOWNTIME_REASON = "No new projects should be created during data copy" def up if Gitlab::Database.postgresql? diff --git a/db/migrate/20161201155511_create_project_statistics.rb b/db/migrate/20161201155511_create_project_statistics.rb index 6dcb5adb82b..175bf0b2a15 100644 --- a/db/migrate/20161201155511_create_project_statistics.rb +++ b/db/migrate/20161201155511_create_project_statistics.rb @@ -5,10 +5,10 @@ class CreateProjectStatistics < ActiveRecord::Migration[4.2] def change # use bigint columns to support values >2GB - counter_column = { limit: 8, null: false, default: 0 } + counter_column = {limit: 8, null: false, default: 0} create_table :project_statistics do |t| - t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } + t.references :project, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade} t.references :namespace, null: false, index: true t.integer :commit_count, counter_column t.integer :storage_size, counter_column diff --git a/db/migrate/20161201160452_migrate_project_statistics.rb b/db/migrate/20161201160452_migrate_project_statistics.rb index 42c5be07e83..306bb4e18f7 100644 --- a/db/migrate/20161201160452_migrate_project_statistics.rb +++ b/db/migrate/20161201160452_migrate_project_statistics.rb @@ -3,7 +3,7 @@ class MigrateProjectStatistics < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Removes two columns from the projects table' + DOWNTIME_REASON = "Removes two columns from the projects table" def up # convert repository_size in float (megabytes) to integer (bytes), diff --git a/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb b/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb index c301d76646e..a884cce52dd 100644 --- a/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb +++ b/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb @@ -10,7 +10,7 @@ class RemoveUniqPathIndexFromNamespace < ActiveRecord::Migration[4.2] DOWNTIME = false def up - constraint_name = 'namespaces_path_key' + constraint_name = "namespaces_path_key" transaction do if index_exists?(:namespaces, :path) diff --git a/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb b/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb index 13660cec7aa..29bfe643700 100644 --- a/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb +++ b/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb @@ -10,7 +10,7 @@ class RemoveUniqNameIndexFromNamespace < ActiveRecord::Migration[4.2] DOWNTIME = false def up - constraint_name = 'namespaces_name_key' + constraint_name = "namespaces_name_key" transaction do if index_exists?(:namespaces, :name) diff --git a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb index 420f0ccb45c..61b28c3d6f6 100644 --- a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb +++ b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb @@ -2,7 +2,7 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Renaming non-unique environments' + DOWNTIME_REASON = "Renaming non-unique environments" def up environments = Arel::Table.new(:environments) diff --git a/db/migrate/20161207231621_create_environment_name_unique_index.rb b/db/migrate/20161207231621_create_environment_name_unique_index.rb index 28d22664405..7b6c9f5b91c 100644 --- a/db/migrate/20161207231621_create_environment_name_unique_index.rb +++ b/db/migrate/20161207231621_create_environment_name_unique_index.rb @@ -5,7 +5,7 @@ class CreateEnvironmentNameUniqueIndex < ActiveRecord::Migration[4.2] disable_ddl_transaction! DOWNTIME = true - DOWNTIME_REASON = 'Making a non-unique index into a unique index' + DOWNTIME_REASON = "Making a non-unique index into a unique index" def up remove_index :environments, [:project_id, :name] diff --git a/db/migrate/20161207231626_add_environment_slug.rb b/db/migrate/20161207231626_add_environment_slug.rb index 993b9bd3330..302dfc1a065 100644 --- a/db/migrate/20161207231626_add_environment_slug.rb +++ b/db/migrate/20161207231626_add_environment_slug.rb @@ -5,11 +5,11 @@ class AddEnvironmentSlug < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Adding NOT NULL column environments.slug with dependent data' + DOWNTIME_REASON = "Adding NOT NULL column environments.slug with dependent data" # Used to generate random suffixes for the slug - LETTERS = 'a'..'z' - NUMBERS = '0'..'9' + LETTERS = "a".."z" + NUMBERS = "0".."9" SUFFIX_CHARS = LETTERS.to_a + NUMBERS.to_a def up @@ -37,25 +37,25 @@ class AddEnvironmentSlug < ActiveRecord::Migration[4.2] # Copy of the Environment#generate_slug implementation def generate_slug(name) # Lowercase letters and numbers only - slugified = name.to_s.downcase.gsub(/[^a-z0-9]/, '-') + slugified = name.to_s.downcase.gsub(/[^a-z0-9]/, "-") # Must start with a letter - slugified = 'env-' + slugified unless LETTERS.cover?(slugified[0]) + slugified = "env-" + slugified unless LETTERS.cover?(slugified[0]) # Repeated dashes are invalid (OpenShift limitation) - slugified.gsub!(/\-+/, '-') + slugified.gsub!(/\-+/, "-") # Maximum length: 24 characters (OpenShift limitation) slugified = slugified[0..23] # Cannot end with a dash (Kubernetes label limitation) - slugified.chop! if slugified.end_with?('-') + slugified.chop! if slugified.end_with?("-") # Add a random suffix, shortening the current string if necessary, if it # has been slugified. This ensures uniqueness. if slugified != name slugified = slugified[0..16] - slugified << '-' unless slugified.end_with?('-') + slugified << "-" unless slugified.end_with?("-") slugified << random_suffix end diff --git a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb index 57606a33cb9..caf96f6d6c8 100644 --- a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb +++ b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb @@ -6,7 +6,7 @@ class AddUniqueIndexForEnvironmentSlug < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Adding a *unique* index to environments.slug' + DOWNTIME_REASON = "Adding a *unique* index to environments.slug" disable_ddl_transaction! diff --git a/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb b/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb index e8ea9cf8fda..0d3ade1980a 100644 --- a/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb +++ b/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb @@ -14,20 +14,20 @@ class CreateDoorkeeperOpenidConnectTables < ActiveRecord::Migration[4.2] if Gitlab::Database.postgresql? # add foreign key without validation to avoid downtime on PostgreSQL, # also see db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb - execute %q{ + execute ' ALTER TABLE "oauth_openid_requests" ADD CONSTRAINT "fk_oauth_openid_requests_oauth_access_grants_access_grant_id" FOREIGN KEY ("access_grant_id") REFERENCES "oauth_access_grants" ("id") NOT VALID; - } + ' else - execute %q{ + execute ' ALTER TABLE oauth_openid_requests ADD CONSTRAINT fk_oauth_openid_requests_oauth_access_grants_access_grant_id FOREIGN KEY (access_grant_id) REFERENCES oauth_access_grants (id); - } + ' end end diff --git a/db/migrate/20161212142807_add_lower_path_index_to_routes.rb b/db/migrate/20161212142807_add_lower_path_index_to_routes.rb index 92a12dbc699..d571985f612 100644 --- a/db/migrate/20161212142807_add_lower_path_index_to_routes.rb +++ b/db/migrate/20161212142807_add_lower_path_index_to_routes.rb @@ -12,7 +12,7 @@ class AddLowerPathIndexToRoutes < ActiveRecord::Migration[4.2] def up return unless Gitlab::Database.postgresql? - execute 'CREATE INDEX CONCURRENTLY index_on_routes_lower_path ON routes (LOWER(path));' + execute "CREATE INDEX CONCURRENTLY index_on_routes_lower_path ON routes (LOWER(path));" end def down diff --git a/db/migrate/20161220141214_remove_dot_git_from_group_names.rb b/db/migrate/20161220141214_remove_dot_git_from_group_names.rb index 5c0b083325e..44e486353e4 100644 --- a/db/migrate/20161220141214_remove_dot_git_from_group_names.rb +++ b/db/migrate/20161220141214_remove_dot_git_from_group_names.rb @@ -10,18 +10,18 @@ class RemoveDotGitFromGroupNames < ActiveRecord::Migration[4.2] def up invalid_groups.each do |group| - path_was = group['path'] + path_was = group["path"] path_was_wildcard = quote_string("#{path_was}/%") path = quote_string(rename_path(path_was)) - move_namespace(group['id'], path_was, path) + move_namespace(group["id"], path_was, path) - execute "UPDATE routes SET path = '#{path}' WHERE source_type = 'Namespace' AND source_id = #{group['id']}" - execute "UPDATE namespaces SET path = '#{path}' WHERE id = #{group['id']}" + execute "UPDATE routes SET path = '#{path}' WHERE source_type = 'Namespace' AND source_id = #{group["id"]}" + execute "UPDATE namespaces SET path = '#{path}' WHERE id = #{group["id"]}" select_all("SELECT id, path FROM routes WHERE path LIKE '#{path_was_wildcard}'").each do |route| - new_path = "#{path}/#{route['path'].split('/').last}" - execute "UPDATE routes SET path = '#{new_path}' WHERE id = #{route['id']}" + new_path = "#{path}/#{route["path"].split("/").last}" + execute "UPDATE routes SET path = '#{new_path}' WHERE id = #{route["id"]}" end end end @@ -45,7 +45,7 @@ class RemoveDotGitFromGroupNames < ActiveRecord::Migration[4.2] def rename_path(path) # To stay closer with original name and reduce risk of duplicates # we rename suffix instead of removing it - path = path.sub(/\.git\z/, '_git') + path = path.sub(/\.git\z/, "_git") counter = 0 base = path @@ -59,9 +59,9 @@ class RemoveDotGitFromGroupNames < ActiveRecord::Migration[4.2] end def move_namespace(group_id, path_was, path) - repository_storages = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{group_id}").map do |row| - row['repository_storage'] - end.compact + repository_storages = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{group_id}").map { |row| + row["repository_storage"] + }.compact # Move the namespace directory in all storages paths used by member projects repository_storages.each do |repository_storage| @@ -73,7 +73,7 @@ class RemoveDotGitFromGroupNames < ActiveRecord::Migration[4.2] # if we cannot move namespace directory we should rollback # db changes in order to prevent out of sync between db and fs - raise Exception.new('namespace directory cannot be moved') + raise Exception.new("namespace directory cannot be moved") end end diff --git a/db/migrate/20161226122833_remove_dot_git_from_usernames.rb b/db/migrate/20161226122833_remove_dot_git_from_usernames.rb index e3318780151..fb1b67efea4 100644 --- a/db/migrate/20161226122833_remove_dot_git_from_usernames.rb +++ b/db/migrate/20161226122833_remove_dot_git_from_usernames.rb @@ -6,9 +6,9 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration[4.2] def up invalid_users.each do |user| - id = user['id'] - namespace_id = user['namespace_id'] - path_was = user['username'] + id = user["id"] + namespace_id = user["namespace_id"] + path_was = user["username"] path_was_wildcard = quote_string("#{path_was}/%") path = quote_string(new_path(path_was)) @@ -20,8 +20,8 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration[4.2] execute "UPDATE users SET username = '#{path}' WHERE id = #{id}" select_all("SELECT id, path FROM routes WHERE path LIKE '#{path_was_wildcard}'").each do |route| - new_path = "#{path}/#{route['path'].split('/').last}" - execute "UPDATE routes SET path = '#{new_path}' WHERE id = #{route['id']}" + new_path = "#{path}/#{route["path"].split("/").last}" + execute "UPDATE routes SET path = '#{new_path}' WHERE id = #{route["id"]}" end rescue => e say("Couldn't update routes for path #{path_was} to #{path}") @@ -58,7 +58,7 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration[4.2] def new_path(path) # To stay closer with original name and reduce risk of duplicates # we rename suffix instead of removing it - path = path.sub(/\.git\z/, '_git') + path = path.sub(/\.git\z/, "_git") check_routes(path.dup, 0, path) end @@ -79,9 +79,9 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration[4.2] end def move_namespace(namespace_id, path_was, path) - repository_storages = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{namespace_id}").map do |row| - row['repository_storage'] - end.compact + repository_storages = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{namespace_id}").map { |row| + row["repository_storage"] + }.compact # Move the namespace directory in all storages used by member projects repository_storages.each do |repository_storage| @@ -93,7 +93,7 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration[4.2] # if we cannot move namespace directory we should rollback # db changes in order to prevent out of sync between db and fs - raise Exception.new('namespace directory cannot be moved') + raise Exception.new("namespace directory cannot be moved") end end diff --git a/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb b/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb index df5714278f2..3fe32a0a79d 100644 --- a/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb +++ b/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb @@ -7,22 +7,22 @@ class RenameSlackAndMattermostNotificationServices < ActiveRecord::Migration[4.2 disable_ddl_transaction! def up - update_column_in_batches(:services, :type, 'SlackService') do |table, query| - query.where(table[:type].eq('SlackNotificationService')) + update_column_in_batches(:services, :type, "SlackService") do |table, query| + query.where(table[:type].eq("SlackNotificationService")) end - update_column_in_batches(:services, :type, 'MattermostService') do |table, query| - query.where(table[:type].eq('MattermostNotificationService')) + update_column_in_batches(:services, :type, "MattermostService") do |table, query| + query.where(table[:type].eq("MattermostNotificationService")) end end def down - update_column_in_batches(:services, :type, 'SlackNotificationService') do |table, query| - query.where(table[:type].eq('SlackService')) + update_column_in_batches(:services, :type, "SlackNotificationService") do |table, query| + query.where(table[:type].eq("SlackService")) end - update_column_in_batches(:services, :type, 'MattermostNotificationService') do |table, query| - query.where(table[:type].eq('MattermostService')) + update_column_in_batches(:services, :type, "MattermostNotificationService") do |table, query| + query.where(table[:type].eq("MattermostService")) end end end diff --git a/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb b/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb index f9f8f11316d..61dedb2b007 100644 --- a/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb +++ b/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb @@ -7,7 +7,7 @@ class ChangeExpiresAtToDateInPersonalAccessTokens < ActiveRecord::Migration[4.2] # Set this constant to true if this migration requires downtime. DOWNTIME = true - DOWNTIME_REASON = 'This migration requires downtime because it alters expires_at column from datetime to date' + DOWNTIME_REASON = "This migration requires downtime because it alters expires_at column from datetime to date" def up change_column :personal_access_tokens, :expires_at, :date diff --git a/db/migrate/20170120131253_create_chat_teams.rb b/db/migrate/20170120131253_create_chat_teams.rb index e9b9bd7bd2f..d05af314cfc 100644 --- a/db/migrate/20170120131253_create_chat_teams.rb +++ b/db/migrate/20170120131253_create_chat_teams.rb @@ -9,7 +9,7 @@ class CreateChatTeams < ActiveRecord::Migration[4.2] def change create_table :chat_teams do |t| - t.references :namespace, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } + t.references :namespace, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade} t.string :team_id t.string :name diff --git a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb index ffd966be086..bb857c4ed9f 100644 --- a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb +++ b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb @@ -9,7 +9,7 @@ class AddForeignKeysToTimelogs < ActiveRecord::Migration[4.2] # When a migration requires downtime you **must** uncomment the following # constant and define a short and easy to understand explanation as to why the # migration requires downtime. - DOWNTIME_REASON = '' + DOWNTIME_REASON = "" # When using the methods "add_concurrent_index" or "add_column_with_default" # you must disable the use of transactions as these methods can not run in an @@ -41,16 +41,16 @@ class AddForeignKeysToTimelogs < ActiveRecord::Migration[4.2] execute "ALTER TABLE timelogs ADD CONSTRAINT fk_timelogs_merge_requests_merge_request_id FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;" end - Timelog.where(trackable_type: 'Issue').update_all("issue_id = trackable_id") - Timelog.where(trackable_type: 'MergeRequest').update_all("merge_request_id = trackable_id") + Timelog.where(trackable_type: "Issue").update_all("issue_id = trackable_id") + Timelog.where(trackable_type: "MergeRequest").update_all("merge_request_id = trackable_id") end def down - Timelog.where('issue_id IS NOT NULL').update_all("trackable_id = issue_id, trackable_type = 'Issue'") - Timelog.where('merge_request_id IS NOT NULL').update_all("trackable_id = merge_request_id, trackable_type = 'MergeRequest'") + Timelog.where("issue_id IS NOT NULL").update_all("trackable_id = issue_id, trackable_type = 'Issue'") + Timelog.where("merge_request_id IS NOT NULL").update_all("trackable_id = merge_request_id, trackable_type = 'MergeRequest'") - remove_foreign_key :timelogs, name: 'fk_timelogs_issues_issue_id' - remove_foreign_key :timelogs, name: 'fk_timelogs_merge_requests_merge_request_id' + remove_foreign_key :timelogs, name: "fk_timelogs_issues_issue_id" + remove_foreign_key :timelogs, name: "fk_timelogs_merge_requests_merge_request_id" remove_columns :timelogs, :issue_id, :merge_request_id end diff --git a/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb b/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb index 84814c2f8f2..2f3ac5717e9 100644 --- a/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb +++ b/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb @@ -6,6 +6,6 @@ class AddDefaultArtifactsExpirationToApplicationSettings < ActiveRecord::Migrati def change add_column :application_settings, :default_artifacts_expire_in, :string, - null: false, default: '0' + null: false, default: "0" end end diff --git a/db/migrate/20170217132157_rename_merge_when_build_succeeds.rb b/db/migrate/20170217132157_rename_merge_when_build_succeeds.rb index ee8838eff56..d492ed74589 100644 --- a/db/migrate/20170217132157_rename_merge_when_build_succeeds.rb +++ b/db/migrate/20170217132157_rename_merge_when_build_succeeds.rb @@ -10,7 +10,7 @@ class RenameMergeWhenBuildSucceeds < ActiveRecord::Migration[4.2] # When a migration requires downtime you **must** uncomment the following # constant and define a short and easy to understand explanation as to why the # migration requires downtime. - DOWNTIME_REASON = 'Renaming the column merge_when_build_succeeds' + DOWNTIME_REASON = "Renaming the column merge_when_build_succeeds" # When using the methods "add_concurrent_index" or "add_column_with_default" # you must disable the use of transactions as these methods can not run in an diff --git a/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb b/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb index 5d35216f3af..80b8e79dd74 100644 --- a/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb +++ b/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb @@ -10,7 +10,7 @@ class RenameOnlyAllowMergeIfBuildSucceeds < ActiveRecord::Migration[4.2] # When a migration requires downtime you **must** uncomment the following # constant and define a short and easy to understand explanation as to why the # migration requires downtime. - DOWNTIME_REASON = 'Renaming the column only_allow_merge_if_build_succeeds' + DOWNTIME_REASON = "Renaming the column only_allow_merge_if_build_succeeds" # When using the methods "add_concurrent_index" or "add_column_with_default" # you must disable the use of transactions as these methods can not run in an diff --git a/db/migrate/20170222111732_create_gpg_keys.rb b/db/migrate/20170222111732_create_gpg_keys.rb index 012e8ef5854..c0c5e689f43 100644 --- a/db/migrate/20170222111732_create_gpg_keys.rb +++ b/db/migrate/20170222111732_create_gpg_keys.rb @@ -7,7 +7,7 @@ class CreateGpgKeys < ActiveRecord::Migration[4.2] create_table :gpg_keys do |t| t.timestamps_with_timezone null: false - t.references :user, index: true, foreign_key: { on_delete: :cascade } + t.references :user, index: true, foreign_key: {on_delete: :cascade} t.binary :primary_keyid t.binary :fingerprint diff --git a/db/migrate/20170222143500_remove_old_project_id_columns.rb b/db/migrate/20170222143500_remove_old_project_id_columns.rb index 356dee4a060..e5b640085af 100644 --- a/db/migrate/20170222143500_remove_old_project_id_columns.rb +++ b/db/migrate/20170222143500_remove_old_project_id_columns.rb @@ -5,7 +5,7 @@ class RemoveOldProjectIdColumns < ActiveRecord::Migration[4.2] disable_ddl_transaction! DOWNTIME = true - DOWNTIME_REASON = 'Unused columns are being removed.' + DOWNTIME_REASON = "Unused columns are being removed." def up remove_index :ci_builds, :project_id if diff --git a/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb b/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb index 390b2c33d91..42a4a8dfae9 100644 --- a/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb +++ b/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb @@ -2,7 +2,7 @@ class RenameGlProjectIdToProjectId < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Renaming an actively used column.' + DOWNTIME_REASON = "Renaming an actively used column." def change rename_column :ci_builds, :gl_project_id, :project_id diff --git a/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb b/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb index 791e9c845a6..00c617624a3 100644 --- a/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb +++ b/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb @@ -2,9 +2,9 @@ class RenameCiCommitsToCiPipelines < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Rename table ci_commits to ci_pipelines' + DOWNTIME_REASON = "Rename table ci_commits to ci_pipelines" def change - rename_table 'ci_commits', 'ci_pipelines' + rename_table "ci_commits", "ci_pipelines" end end diff --git a/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb b/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb index 08a11aee992..51f24ed7bca 100644 --- a/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb +++ b/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb @@ -4,8 +4,8 @@ class RemoveUnusedCiTablesAndColumns < ActiveRecord::Migration[4.2] DOWNTIME = true DOWNTIME_REASON = - 'Remove unused columns in used tables.' \ - ' Downtime required in case Rails caches them' + "Remove unused columns in used tables." \ + " Downtime required in case Rails caches them" def up %w[ci_application_settings diff --git a/db/migrate/20170309173138_create_protected_tags.rb b/db/migrate/20170309173138_create_protected_tags.rb index f518b500bd4..de203448a8a 100644 --- a/db/migrate/20170309173138_create_protected_tags.rb +++ b/db/migrate/20170309173138_create_protected_tags.rb @@ -16,7 +16,7 @@ class CreateProtectedTags < ActiveRecord::Migration[4.2] add_index :protected_tags, :project_id create_table :protected_tag_create_access_levels do |t| - t.references :protected_tag, index: { name: "index_protected_tag_create_access" }, foreign_key: true, null: false + t.references :protected_tag, index: {name: "index_protected_tag_create_access"}, foreign_key: true, null: false t.integer :access_level, default: GITLAB_ACCESS_MASTER, null: true t.references :user, foreign_key: true, index: true t.integer :group_id diff --git a/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb b/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb index a2b5c1c4533..101dd9acc7b 100644 --- a/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb +++ b/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb @@ -10,7 +10,7 @@ class AddAutoCanceledByIdForeignKeyToPipeline < ActiveRecord::Migration[4.2] if Gitlab::Database.mysql? :nullify else - 'SET NULL' + "SET NULL" end add_concurrent_foreign_key :ci_pipelines, :ci_pipelines, column: :auto_canceled_by_id, on_delete: on_delete diff --git a/db/migrate/20170316163845_move_uploads_to_system_dir.rb b/db/migrate/20170316163845_move_uploads_to_system_dir.rb index d24527b55cd..b37190c916e 100644 --- a/db/migrate/20170316163845_move_uploads_to_system_dir.rb +++ b/db/migrate/20170316163845_move_uploads_to_system_dir.rb @@ -6,7 +6,7 @@ class MoveUploadsToSystemDir < ActiveRecord::Migration[4.2] disable_ddl_transaction! DOWNTIME = false - DIRECTORIES_TO_MOVE = %w(user project note group appearance).freeze + DIRECTORIES_TO_MOVE = %w[user project note group appearance].freeze def up return unless file_storage? diff --git a/db/migrate/20170317203554_index_routes_path_for_like.rb b/db/migrate/20170317203554_index_routes_path_for_like.rb index a1bee3c8783..a3d5a102aaa 100644 --- a/db/migrate/20170317203554_index_routes_path_for_like.rb +++ b/db/migrate/20170317203554_index_routes_path_for_like.rb @@ -7,7 +7,7 @@ class IndexRoutesPathForLike < ActiveRecord::Migration[4.2] # Set this constant to true if this migration requires downtime. DOWNTIME = false - INDEX_NAME = 'index_routes_on_path_text_pattern_ops' + INDEX_NAME = "index_routes_on_path_text_pattern_ops" disable_ddl_transaction! diff --git a/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb b/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb index 2ec281e20c1..1f96c3c8e90 100644 --- a/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb +++ b/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb @@ -10,7 +10,7 @@ class AddAutoCanceledByIdForeignKeyToCiBuilds < ActiveRecord::Migration[4.2] if Gitlab::Database.mysql? :nullify else - 'SET NULL' + "SET NULL" end add_concurrent_foreign_key :ci_builds, :ci_pipelines, column: :auto_canceled_by_id, on_delete: on_delete diff --git a/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb b/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb index 1c5d4997d40..3a9d32d4f66 100644 --- a/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb +++ b/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb @@ -1 +1 @@ -require_relative 'markdown_cache_limits_to_mysql' +require_relative "markdown_cache_limits_to_mysql" diff --git a/db/migrate/20170503140201_reschedule_project_authorizations.rb b/db/migrate/20170503140201_reschedule_project_authorizations.rb index aa940bed2d3..2168510047e 100644 --- a/db/migrate/20170503140201_reschedule_project_authorizations.rb +++ b/db/migrate/20170503140201_reschedule_project_authorizations.rb @@ -9,7 +9,7 @@ class RescheduleProjectAuthorizations < ActiveRecord::Migration[4.2] disable_ddl_transaction! class User < ActiveRecord::Base - self.table_name = 'users' + self.table_name = "users" end def up @@ -18,7 +18,7 @@ class RescheduleProjectAuthorizations < ActiveRecord::Migration[4.2] start = Time.now loop do - relation = User.where('id > ?', offset) + relation = User.where("id > ?", offset) user_ids = relation.limit(batch).reorder(id: :asc).pluck(:id) break if user_ids.empty? @@ -29,10 +29,10 @@ class RescheduleProjectAuthorizations < ActiveRecord::Migration[4.2] # scheduled. This smears out the load over time, instead of immediately # scheduling a million jobs. Sidekiq::Client.push_bulk( - 'queue' => 'authorized_projects', - 'args' => user_ids.zip, - 'class' => 'AuthorizedProjectsWorker', - 'at' => start.to_i + "queue" => "authorized_projects", + "args" => user_ids.zip, + "class" => "AuthorizedProjectsWorker", + "at" => start.to_i ) start += 5.minutes diff --git a/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb b/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb index cfa63b65df4..9705fce9721 100644 --- a/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb +++ b/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb @@ -25,7 +25,7 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration[4.2] # 2. Get all the members of these namespaces, along with their higher access # level # 3. Give these members access to the current namespace - Namespace.unscoped.where('parent_id IS NOT NULL').find_each do |namespace| + Namespace.unscoped.where("parent_id IS NOT NULL").find_each do |namespace| rows = [] existing = namespace.members.pluck(:user_id) @@ -35,12 +35,12 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration[4.2] rows << { access_level: member[:access_level], source_id: namespace.id, - source_type: 'Namespace', + source_type: "Namespace", user_id: member[:user_id], notification_level: 3, # global - type: 'GroupMember', + type: "GroupMember", created_at: Time.current, - updated_at: Time.current + updated_at: Time.current, } end @@ -64,7 +64,7 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration[4.2] # Generates a new (unique) path for a namespace. def new_path_for(namespace) counter = 1 - base = namespace.full_path.tr('/', '-') + base = namespace.full_path.tr("/", "-") new_path = base while Namespace.unscoped.where(path: new_path).exists? @@ -101,8 +101,8 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration[4.2] def all_members_for(namespace) Member .unscoped - .select(['user_id', 'MAX(access_level) AS access_level']) - .where(source_type: 'Namespace', source_id: ancestors_for(namespace)) + .select(["user_id", "MAX(access_level) AS access_level"]) + .where(source_type: "Namespace", source_id: ancestors_for(namespace)) .group(:user_id) end @@ -111,13 +111,13 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration[4.2] keys = rows.first.keys - tuples = rows.map do |row| + tuples = rows.map { |row| row.map { |(_, value)| connection.quote(value) } - end + } execute <<-EOF.strip_heredoc - INSERT INTO members (#{keys.join(', ')}) - VALUES #{tuples.map { |tuple| "(#{tuple.join(', ')})" }.join(', ')} + INSERT INTO members (#{keys.join(", ")}) + VALUES #{tuples.map { |tuple| "(#{tuple.join(", ")})" }.join(", ")} EOF end end diff --git a/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb b/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb index 5d06fd0511c..0ec437076fb 100644 --- a/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb +++ b/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb @@ -7,7 +7,7 @@ class IndexRedirectRoutesPathForLike < ActiveRecord::Migration[4.2] # Set this constant to true if this migration requires downtime. DOWNTIME = false - INDEX_NAME = 'index_redirect_routes_on_path_text_pattern_ops' + INDEX_NAME = "index_redirect_routes_on_path_text_pattern_ops" disable_ddl_transaction! diff --git a/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb b/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb index 50364cac259..1601c793ad8 100644 --- a/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb +++ b/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb @@ -10,7 +10,7 @@ class AddForeignKeyPipelineSchedulesAndPipelines < ActiveRecord::Migration[4.2] if Gitlab::Database.mysql? :nullify else - 'SET NULL' + "SET NULL" end add_concurrent_foreign_key :ci_pipelines, :ci_pipeline_schedules, diff --git a/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb b/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb index 0ed45775421..edd717df468 100644 --- a/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb +++ b/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb @@ -35,7 +35,7 @@ class MigrateAssigneeToSeparateTable < ActiveRecord::Migration[4.2] EOF else ActiveRecord::Base.transaction do - execute('LOCK TABLE issues IN EXCLUSIVE MODE') + execute("LOCK TABLE issues IN EXCLUSIVE MODE") execute <<-EOF CREATE TABLE issue_assignees AS diff --git a/db/migrate/20170516183131_add_indices_to_issue_assignees.rb b/db/migrate/20170516183131_add_indices_to_issue_assignees.rb index 6877fe9ff98..b5c171fc88a 100644 --- a/db/migrate/20170516183131_add_indices_to_issue_assignees.rb +++ b/db/migrate/20170516183131_add_indices_to_issue_assignees.rb @@ -26,8 +26,8 @@ class AddIndicesToIssueAssignees < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - add_concurrent_index :issue_assignees, [:issue_id, :user_id], unique: true, name: 'index_issue_assignees_on_issue_id_and_user_id' - add_concurrent_index :issue_assignees, :user_id, name: 'index_issue_assignees_on_user_id' + add_concurrent_index :issue_assignees, [:issue_id, :user_id], unique: true, name: "index_issue_assignees_on_issue_id_and_user_id" + add_concurrent_index :issue_assignees, :user_id, name: "index_issue_assignees_on_user_id" add_concurrent_foreign_key :issue_assignees, :users, column: :user_id, on_delete: :cascade add_concurrent_foreign_key :issue_assignees, :issues, column: :issue_id, on_delete: :cascade end diff --git a/db/migrate/20170519102115_add_prometheus_settings_to_metrics_settings.rb b/db/migrate/20170519102115_add_prometheus_settings_to_metrics_settings.rb index 9c8f58104bd..1b9c8159c3b 100644 --- a/db/migrate/20170519102115_add_prometheus_settings_to_metrics_settings.rb +++ b/db/migrate/20170519102115_add_prometheus_settings_to_metrics_settings.rb @@ -7,7 +7,7 @@ class AddPrometheusSettingsToMetricsSettings < ActiveRecord::Migration[4.2] def up add_column_with_default(:application_settings, :prometheus_metrics_enabled, :boolean, - default: false, allow_null: false) + default: false, allow_null: false) end def down diff --git a/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb b/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb index d40c61f24b1..b276774e380 100644 --- a/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb +++ b/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb @@ -43,7 +43,7 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2] [:ci_runner_projects, :projects, :project_id], [:ci_triggers, :projects, :project_id], [:environments, :projects, :project_id], - [:deployments, :projects, :project_id] + [:deployments, :projects, :project_id], ] def up @@ -52,10 +52,10 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2] remove_foreign_key_without_error(:lists, :label_id) remove_foreign_key_without_error(:lists, :board_id) remove_foreign_key_without_error(:protected_branch_merge_access_levels, - :protected_branch_id) + :protected_branch_id) remove_foreign_key_without_error(:protected_branch_push_access_levels, - :protected_branch_id) + :protected_branch_id) remove_orphaned_rows add_foreign_keys @@ -76,12 +76,12 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2] add_foreign_key_if_not_exists(:lists, :boards, column: :board_id) add_foreign_key_if_not_exists(:protected_branch_merge_access_levels, - :protected_branches, - column: :protected_branch_id) + :protected_branches, + column: :protected_branch_id) add_foreign_key_if_not_exists(:protected_branch_push_access_levels, - :protected_branches, - column: :protected_branch_id) + :protected_branches, + column: :protected_branch_id) remove_index_without_error(:project_group_links, :project_id) remove_index_without_error(:pages_domains, :project_id) @@ -98,7 +98,7 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2] Gitlab::Database.with_connection_pool(CONCURRENCY) do |pool| queues = queues_for_rows(TABLES) - threads = queues.map do |queue| + threads = queues.map { |queue| Thread.new do pool.with_connection do |connection| Thread.current[:foreign_key_connection] = connection @@ -113,7 +113,7 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2] end end end - end + } threads.each(&:join) end @@ -126,11 +126,10 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2] queues.each do |queue| # Stealing is racy so it's possible a pop might be called on an # already-empty queue. - begin - remove_orphans(*queue.pop(true)) - stolen = true - rescue ThreadError - end + + remove_orphans(*queue.pop(true)) + stolen = true + rescue ThreadError end break unless stolen diff --git a/db/migrate/20170606154216_add_notification_setting_columns.rb b/db/migrate/20170606154216_add_notification_setting_columns.rb index 3b9493e6b49..cfee4e93b12 100644 --- a/db/migrate/20170606154216_add_notification_setting_columns.rb +++ b/db/migrate/20170606154216_add_notification_setting_columns.rb @@ -15,7 +15,7 @@ class AddNotificationSettingColumns < ActiveRecord::Migration[4.2] :reassign_merge_request, :merge_merge_request, :failed_pipeline, - :success_pipeline + :success_pipeline, ] def change diff --git a/db/migrate/20170608152747_prepare_events_table_for_push_events_migration.rb b/db/migrate/20170608152747_prepare_events_table_for_push_events_migration.rb index 851af7f7bf6..b1a23800261 100644 --- a/db/migrate/20170608152747_prepare_events_table_for_push_events_migration.rb +++ b/db/migrate/20170608152747_prepare_events_table_for_push_events_migration.rb @@ -26,8 +26,8 @@ class PrepareEventsTableForPushEventsMigration < ActiveRecord::Migration[4.2] # does not support this properly. create_table :events_for_migration do |t| t.references :project, - index: true, - foreign_key: { on_delete: :cascade } + index: true, + foreign_key: {on_delete: :cascade} t.integer :author_id, index: true, null: false t.integer :target_id diff --git a/db/migrate/20170608171156_create_merge_request_diff_files.rb b/db/migrate/20170608171156_create_merge_request_diff_files.rb index 94b518455ee..c8efb2e6295 100644 --- a/db/migrate/20170608171156_create_merge_request_diff_files.rb +++ b/db/migrate/20170608171156_create_merge_request_diff_files.rb @@ -5,7 +5,7 @@ class CreateMergeRequestDiffFiles < ActiveRecord::Migration[4.2] def change create_table :merge_request_diff_files, id: false do |t| - t.belongs_to :merge_request_diff, null: false, foreign_key: { on_delete: :cascade } + t.belongs_to :merge_request_diff, null: false, foreign_key: {on_delete: :cascade} t.integer :relative_order, null: false t.boolean :new_file, null: false t.boolean :renamed_file, null: false @@ -16,7 +16,7 @@ class CreateMergeRequestDiffFiles < ActiveRecord::Migration[4.2] t.text :new_path, null: false t.text :old_path, null: false t.text :diff, null: false - t.index [:merge_request_diff_id, :relative_order], name: 'index_merge_request_diff_files_on_mr_diff_id_and_order', unique: true + t.index [:merge_request_diff_id, :relative_order], name: "index_merge_request_diff_files_on_mr_diff_id_and_order", unique: true end end end diff --git a/db/migrate/20170613154149_create_gpg_signatures.rb b/db/migrate/20170613154149_create_gpg_signatures.rb index 181d35fe7af..9923ba00c2f 100644 --- a/db/migrate/20170613154149_create_gpg_signatures.rb +++ b/db/migrate/20170613154149_create_gpg_signatures.rb @@ -7,8 +7,8 @@ class CreateGpgSignatures < ActiveRecord::Migration[4.2] create_table :gpg_signatures do |t| t.timestamps_with_timezone null: false - t.references :project, index: true, foreign_key: { on_delete: :cascade } - t.references :gpg_key, index: true, foreign_key: { on_delete: :nullify } + t.references :project, index: true, foreign_key: {on_delete: :cascade} + t.references :gpg_key, index: true, foreign_key: {on_delete: :nullify} t.boolean :valid_signature diff --git a/db/migrate/20170614115405_merge_request_diff_file_limits_to_mysql.rb b/db/migrate/20170614115405_merge_request_diff_file_limits_to_mysql.rb index 4c1cf08aa06..1428b4efe3e 100644 --- a/db/migrate/20170614115405_merge_request_diff_file_limits_to_mysql.rb +++ b/db/migrate/20170614115405_merge_request_diff_file_limits_to_mysql.rb @@ -1 +1 @@ -require_relative 'merge_request_diff_file_limits_to_mysql' +require_relative "merge_request_diff_file_limits_to_mysql" diff --git a/db/migrate/20170616133147_create_merge_request_diff_commits.rb b/db/migrate/20170616133147_create_merge_request_diff_commits.rb index 5e148affba2..6b4951f5e82 100644 --- a/db/migrate/20170616133147_create_merge_request_diff_commits.rb +++ b/db/migrate/20170616133147_create_merge_request_diff_commits.rb @@ -5,7 +5,7 @@ class CreateMergeRequestDiffCommits < ActiveRecord::Migration[4.2] create_table :merge_request_diff_commits, id: false do |t| t.datetime_with_timezone :authored_date t.datetime_with_timezone :committed_date - t.belongs_to :merge_request_diff, null: false, foreign_key: { on_delete: :cascade } + t.belongs_to :merge_request_diff, null: false, foreign_key: {on_delete: :cascade} t.integer :relative_order, null: false t.binary :sha, null: false, limit: 20 t.text :author_name @@ -14,7 +14,7 @@ class CreateMergeRequestDiffCommits < ActiveRecord::Migration[4.2] t.text :committer_email t.text :message - t.index [:merge_request_diff_id, :relative_order], name: 'index_merge_request_diff_commits_on_mr_diff_id_and_order', unique: true + t.index [:merge_request_diff_id, :relative_order], name: "index_merge_request_diff_commits_on_mr_diff_id_and_order", unique: true end end end diff --git a/db/migrate/20170622130029_correct_protected_branches_foreign_keys.rb b/db/migrate/20170622130029_correct_protected_branches_foreign_keys.rb index c4ba3ec2cc0..b471cd468ce 100644 --- a/db/migrate/20170622130029_correct_protected_branches_foreign_keys.rb +++ b/db/migrate/20170622130029_correct_protected_branches_foreign_keys.rb @@ -11,7 +11,7 @@ class CorrectProtectedBranchesForeignKeys < ActiveRecord::Migration[4.2] def up remove_foreign_key_without_error(:protected_branch_push_access_levels, - column: :protected_branch_id) + column: :protected_branch_id) execute <<-EOF DELETE FROM protected_branch_push_access_levels @@ -24,8 +24,8 @@ class CorrectProtectedBranchesForeignKeys < ActiveRecord::Migration[4.2] EOF add_concurrent_foreign_key(:protected_branch_push_access_levels, - :protected_branches, - column: :protected_branch_id) + :protected_branches, + column: :protected_branch_id) end def down diff --git a/db/migrate/20170622132212_add_foreign_key_for_merge_request_diffs.rb b/db/migrate/20170622132212_add_foreign_key_for_merge_request_diffs.rb index b826f67ff39..262da61c4bf 100644 --- a/db/migrate/20170622132212_add_foreign_key_for_merge_request_diffs.rb +++ b/db/migrate/20170622132212_add_foreign_key_for_merge_request_diffs.rb @@ -20,8 +20,8 @@ class AddForeignKeyForMergeRequestDiffs < ActiveRecord::Migration[4.2] EOF add_concurrent_foreign_key(:merge_request_diffs, - :merge_requests, - column: :merge_request_id) + :merge_requests, + column: :merge_request_id) end def down diff --git a/db/migrate/20170622135451_rename_duplicated_variable_key.rb b/db/migrate/20170622135451_rename_duplicated_variable_key.rb index 06a9529ae79..681c40b70a2 100644 --- a/db/migrate/20170622135451_rename_duplicated_variable_key.rb +++ b/db/migrate/20170622135451_rename_duplicated_variable_key.rb @@ -29,10 +29,10 @@ class RenameDuplicatedVariableKey < ActiveRecord::Migration[4.2] def key # key needs to be quoted in MySQL - quote_column_name('key') + quote_column_name("key") end def underscore - quote('_') + quote("_") end end diff --git a/db/migrate/20170622135628_add_environment_scope_to_ci_variables.rb b/db/migrate/20170622135628_add_environment_scope_to_ci_variables.rb index 8fbb2ab57d5..8858000439f 100644 --- a/db/migrate/20170622135628_add_environment_scope_to_ci_variables.rb +++ b/db/migrate/20170622135628_add_environment_scope_to_ci_variables.rb @@ -6,7 +6,7 @@ class AddEnvironmentScopeToCiVariables < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - add_column_with_default(:ci_variables, :environment_scope, :string, default: '*') + add_column_with_default(:ci_variables, :environment_scope, :string, default: "*") end def down diff --git a/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb b/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb index 240f55766d3..2fcac79df3b 100644 --- a/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb +++ b/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb @@ -2,7 +2,7 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'index_ci_variables_on_project_id_and_key_and_environment_scope' + INDEX_NAME = "index_ci_variables_on_project_id_and_key_and_environment_scope" disable_ddl_transaction! diff --git a/db/migrate/20170710083355_clean_stage_id_reference_migration.rb b/db/migrate/20170710083355_clean_stage_id_reference_migration.rb index d33c6f53b15..11f40fee6b2 100644 --- a/db/migrate/20170710083355_clean_stage_id_reference_migration.rb +++ b/db/migrate/20170710083355_clean_stage_id_reference_migration.rb @@ -9,7 +9,7 @@ class CleanStageIdReferenceMigration < ActiveRecord::Migration[4.2] # `MigrateStageIdReferenceInBackground` background migration cleanup. # def up - Gitlab::BackgroundMigration.steal('MigrateBuildStageIdReference') + Gitlab::BackgroundMigration.steal("MigrateBuildStageIdReference") end def down diff --git a/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb b/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb index 908b122c659..69bbce20eaf 100644 --- a/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb +++ b/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb @@ -6,7 +6,7 @@ class AddForeignKeyToMergeRequests < ActiveRecord::Migration[4.2] disable_ddl_transaction! class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' + self.table_name = "merge_requests" include ::EachBatch end @@ -25,7 +25,7 @@ class AddForeignKeyToMergeRequests < ActiveRecord::Migration[4.2] unless foreign_key_exists?(:merge_requests, column: :head_pipeline_id) add_concurrent_foreign_key(:merge_requests, :ci_pipelines, - column: :head_pipeline_id, on_delete: :nullify) + column: :head_pipeline_id, on_delete: :nullify) end end diff --git a/db/migrate/20170717074009_move_system_upload_folder.rb b/db/migrate/20170717074009_move_system_upload_folder.rb index 6c57a751c8d..1f8d67be7f9 100644 --- a/db/migrate/20170717074009_move_system_upload_folder.rb +++ b/db/migrate/20170717074009_move_system_upload_folder.rb @@ -6,7 +6,7 @@ class MoveSystemUploadFolder < ActiveRecord::Migration[4.2] def up unless file_storage? - say 'Using object storage, no need to move.' + say "Using object storage, no need to move." return end @@ -20,7 +20,7 @@ class MoveSystemUploadFolder < ActiveRecord::Migration[4.2] return end - FileUtils.mkdir_p(File.join(base_directory, '-')) + FileUtils.mkdir_p(File.join(base_directory, "-")) say "Moving #{old_directory} -> #{new_directory}" FileUtils.mv(old_directory, new_directory) @@ -29,7 +29,7 @@ class MoveSystemUploadFolder < ActiveRecord::Migration[4.2] def down unless file_storage? - say 'Using object storage, no need to move.' + say "Using object storage, no need to move." return end @@ -53,15 +53,15 @@ class MoveSystemUploadFolder < ActiveRecord::Migration[4.2] end def new_directory - File.join(base_directory, '-', 'system') + File.join(base_directory, "-", "system") end def old_directory - File.join(base_directory, 'system') + File.join(base_directory, "system") end def base_directory - File.join(Rails.root, 'public', 'uploads') + File.join(Rails.root, "public", "uploads") end def file_storage? diff --git a/db/migrate/20170720122741_create_user_custom_attributes.rb b/db/migrate/20170720122741_create_user_custom_attributes.rb index 0e6f37d7317..86ade08b83b 100644 --- a/db/migrate/20170720122741_create_user_custom_attributes.rb +++ b/db/migrate/20170720122741_create_user_custom_attributes.rb @@ -6,7 +6,7 @@ class CreateUserCustomAttributes < ActiveRecord::Migration[4.2] def change create_table :user_custom_attributes do |t| t.timestamps_with_timezone null: false - t.references :user, null: false, foreign_key: { on_delete: :cascade } + t.references :user, null: false, foreign_key: {on_delete: :cascade} t.string :key, null: false t.string :value, null: false diff --git a/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb b/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb index 1a6516f8777..86b8e41ad98 100644 --- a/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb +++ b/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb @@ -5,7 +5,7 @@ class AddLowerPathIndexToRedirectRoutes < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'index_on_redirect_routes_lower_path' + INDEX_NAME = "index_on_redirect_routes_lower_path" disable_ddl_transaction! diff --git a/db/migrate/20170803130232_reorganise_issues_indexes_for_faster_sorting.rb b/db/migrate/20170803130232_reorganise_issues_indexes_for_faster_sorting.rb index e92b5f28685..4963c11f2d8 100644 --- a/db/migrate/20170803130232_reorganise_issues_indexes_for_faster_sorting.rb +++ b/db/migrate/20170803130232_reorganise_issues_indexes_for_faster_sorting.rb @@ -14,7 +14,7 @@ class ReorganiseIssuesIndexesForFasterSorting < ActiveRecord::Migration[4.2] ADD_INDEX_COLUMNS = [ %i[project_id created_at id state], %i[project_id due_date id state], - %i[project_id updated_at id state] + %i[project_id updated_at id state], ].freeze TABLE = :issues diff --git a/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb b/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb index fd8cdbb95aa..5c86b188d73 100644 --- a/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb +++ b/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb @@ -10,7 +10,7 @@ class AddBroadcastMessageNotNullConstraints < ActiveRecord::Migration[4.2] COLUMNS = %i[starts_at ends_at created_at updated_at message_html] class BroadcastMessage < ActiveRecord::Base - self.table_name = 'broadcast_messages' + self.table_name = "broadcast_messages" end def up diff --git a/db/migrate/20170816133938_add_access_level_to_ci_runners.rb b/db/migrate/20170816133938_add_access_level_to_ci_runners.rb index 5a1ea9514d1..67ee7205d46 100644 --- a/db/migrate/20170816133938_add_access_level_to_ci_runners.rb +++ b/db/migrate/20170816133938_add_access_level_to_ci_runners.rb @@ -7,7 +7,7 @@ class AddAccessLevelToCiRunners < ActiveRecord::Migration[4.2] def up add_column_with_default(:ci_runners, :access_level, :integer, - default: Ci::Runner.access_levels['not_protected']) + default: Ci::Runner.access_levels["not_protected"]) end def down diff --git a/db/migrate/20170820100558_correct_protected_tags_foreign_keys.rb b/db/migrate/20170820100558_correct_protected_tags_foreign_keys.rb index 82e05885b0e..974aa1f489d 100644 --- a/db/migrate/20170820100558_correct_protected_tags_foreign_keys.rb +++ b/db/migrate/20170820100558_correct_protected_tags_foreign_keys.rb @@ -11,7 +11,7 @@ class CorrectProtectedTagsForeignKeys < ActiveRecord::Migration[4.2] def up remove_foreign_key_without_error(:protected_tag_create_access_levels, - column: :protected_tag_id) + column: :protected_tag_id) execute <<-EOF DELETE FROM protected_tag_create_access_levels @@ -24,8 +24,8 @@ class CorrectProtectedTagsForeignKeys < ActiveRecord::Migration[4.2] EOF add_concurrent_foreign_key(:protected_tag_create_access_levels, - :protected_tags, - column: :protected_tag_id) + :protected_tags, + column: :protected_tag_id) end def down diff --git a/db/migrate/20170820120108_create_user_synced_attributes_metadata.rb b/db/migrate/20170820120108_create_user_synced_attributes_metadata.rb index 131dcf7ac25..0aecfef851d 100644 --- a/db/migrate/20170820120108_create_user_synced_attributes_metadata.rb +++ b/db/migrate/20170820120108_create_user_synced_attributes_metadata.rb @@ -8,7 +8,7 @@ class CreateUserSyncedAttributesMetadata < ActiveRecord::Migration[4.2] t.boolean :name_synced, default: false t.boolean :email_synced, default: false t.boolean :location_synced, default: false - t.references :user, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } + t.references :user, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade} t.string :provider end end diff --git a/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb b/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb index b1adccc9c5c..39d018202f4 100644 --- a/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb +++ b/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb @@ -5,11 +5,11 @@ class MigrateIssuesToGhostUser < ActiveRecord::Migration[4.2] disable_ddl_transaction! class User < ActiveRecord::Base - self.table_name = 'users' + self.table_name = "users" end class Issue < ActiveRecord::Base - self.table_name = 'issues' + self.table_name = "issues" include ::EachBatch end @@ -27,7 +27,7 @@ class MigrateIssuesToGhostUser < ActiveRecord::Migration[4.2] # we use the model method because rewriting it is too complicated and would require copying multiple methods ghost_id = ::User.ghost.id - Issue.where('NOT EXISTS (?)', User.unscoped.select(1).where('issues.author_id = users.id')).each_batch do |relation| + Issue.where("NOT EXISTS (?)", User.unscoped.select(1).where("issues.author_id = users.id")).each_batch do |relation| relation.update_all(author_id: ghost_id) end end diff --git a/db/migrate/20170828093725_create_project_auto_dev_ops.rb b/db/migrate/20170828093725_create_project_auto_dev_ops.rb index ea895dc14c1..a9066028881 100644 --- a/db/migrate/20170828093725_create_project_auto_dev_ops.rb +++ b/db/migrate/20170828093725_create_project_auto_dev_ops.rb @@ -5,7 +5,7 @@ class CreateProjectAutoDevOps < ActiveRecord::Migration[4.2] def up create_table :project_auto_devops do |t| - t.belongs_to :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } + t.belongs_to :project, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade} t.datetime_with_timezone :created_at, null: false t.datetime_with_timezone :updated_at, null: false t.boolean :enabled, default: nil, null: true diff --git a/db/migrate/20170828135939_migrate_user_external_mail_data.rb b/db/migrate/20170828135939_migrate_user_external_mail_data.rb index 9ee4a4598bf..245705174b6 100644 --- a/db/migrate/20170828135939_migrate_user_external_mail_data.rb +++ b/db/migrate/20170828135939_migrate_user_external_mail_data.rb @@ -9,20 +9,20 @@ class MigrateUserExternalMailData < ActiveRecord::Migration[4.2] disable_ddl_transaction! class User < ActiveRecord::Base - self.table_name = 'users' + self.table_name = "users" include EachBatch end class UserSyncedAttributesMetadata < ActiveRecord::Base - self.table_name = 'user_synced_attributes_metadata' + self.table_name = "user_synced_attributes_metadata" include EachBatch end def up User.each_batch do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first + start_id, end_id = batch.pluck("MIN(id), MAX(id)").first execute <<-EOF INSERT INTO user_synced_attributes_metadata (user_id, provider, email_synced) @@ -42,7 +42,7 @@ class MigrateUserExternalMailData < ActiveRecord::Migration[4.2] def down UserSyncedAttributesMetadata.each_batch do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first + start_id, end_id = batch.pluck("MIN(id), MAX(id)").first execute <<-EOF UPDATE users diff --git a/db/migrate/20170830130119_steal_remaining_event_migration_jobs.rb b/db/migrate/20170830130119_steal_remaining_event_migration_jobs.rb index bcc34d56d2d..b28dcb29ea4 100644 --- a/db/migrate/20170830130119_steal_remaining_event_migration_jobs.rb +++ b/db/migrate/20170830130119_steal_remaining_event_migration_jobs.rb @@ -10,7 +10,7 @@ class StealRemainingEventMigrationJobs < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - Gitlab::BackgroundMigration.steal('MigrateEventsToPushEventPayloads') + Gitlab::BackgroundMigration.steal("MigrateEventsToPushEventPayloads") end def down diff --git a/db/migrate/20170830131015_swap_event_migration_tables.rb b/db/migrate/20170830131015_swap_event_migration_tables.rb index fb3b2472ffe..ca544ff6d97 100644 --- a/db/migrate/20170830131015_swap_event_migration_tables.rb +++ b/db/migrate/20170830131015_swap_event_migration_tables.rb @@ -8,7 +8,7 @@ class SwapEventMigrationTables < ActiveRecord::Migration[4.2] DOWNTIME = false class Event < ActiveRecord::Base - self.table_name = 'events' + self.table_name = "events" end def up @@ -40,7 +40,7 @@ class SwapEventMigrationTables < ActiveRecord::Migration[4.2] end def reset_primary_key_for_mysql - amount = Event.pluck('COALESCE(MAX(id), 1)').first + amount = Event.pluck("COALESCE(MAX(id), 1)").first execute "ALTER TABLE #{Event.table_name} AUTO_INCREMENT = #{amount}" end diff --git a/db/migrate/20170912113435_clean_stages_statuses_migration.rb b/db/migrate/20170912113435_clean_stages_statuses_migration.rb index f2040f819cd..7544b409008 100644 --- a/db/migrate/20170912113435_clean_stages_statuses_migration.rb +++ b/db/migrate/20170912113435_clean_stages_statuses_migration.rb @@ -7,14 +7,14 @@ class CleanStagesStatusesMigration < ActiveRecord::Migration[4.2] class Stage < ActiveRecord::Base include ::EachBatch - self.table_name = 'ci_stages' + self.table_name = "ci_stages" end def up - Gitlab::BackgroundMigration.steal('MigrateStageStatus') + Gitlab::BackgroundMigration.steal("MigrateStageStatus") - Stage.where('status IS NULL').each_batch(of: 50) do |batch| - range = batch.pluck('MIN(id)', 'MAX(id)').first + Stage.where("status IS NULL").each_batch(of: 50) do |batch| + range = batch.pluck("MIN(id)", "MAX(id)").first Gitlab::BackgroundMigration::MigrateStageStatus.new.perform(*range) end diff --git a/db/migrate/20170918072948_create_job_artifacts.rb b/db/migrate/20170918072948_create_job_artifacts.rb index 4dd24aaff99..8d11db72279 100644 --- a/db/migrate/20170918072948_create_job_artifacts.rb +++ b/db/migrate/20170918072948_create_job_artifacts.rb @@ -5,7 +5,7 @@ class CreateJobArtifacts < ActiveRecord::Migration[4.2] def change create_table :ci_job_artifacts do |t| - t.belongs_to :project, null: false, index: true, foreign_key: { on_delete: :cascade } + t.belongs_to :project, null: false, index: true, foreign_key: {on_delete: :cascade} t.integer :job_id, null: false t.integer :file_type, null: false t.integer :size, limit: 8 diff --git a/db/migrate/20170918111708_create_project_custom_attributes.rb b/db/migrate/20170918111708_create_project_custom_attributes.rb index bd6064689ff..ccc5a9f2d5f 100644 --- a/db/migrate/20170918111708_create_project_custom_attributes.rb +++ b/db/migrate/20170918111708_create_project_custom_attributes.rb @@ -4,7 +4,7 @@ class CreateProjectCustomAttributes < ActiveRecord::Migration[4.2] def change create_table :project_custom_attributes do |t| t.timestamps_with_timezone null: false - t.references :project, null: false, foreign_key: { on_delete: :cascade } + t.references :project, null: false, foreign_key: {on_delete: :cascade} t.string :key, null: false t.string :value, null: false diff --git a/db/migrate/20170919211300_remove_temporary_ci_builds_index.rb b/db/migrate/20170919211300_remove_temporary_ci_builds_index.rb index 23c94a809d4..52bf67dc5d1 100644 --- a/db/migrate/20170919211300_remove_temporary_ci_builds_index.rb +++ b/db/migrate/20170919211300_remove_temporary_ci_builds_index.rb @@ -11,7 +11,7 @@ class RemoveTemporaryCiBuildsIndex < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - return unless index_exists?(:ci_builds, :id, name: 'index_for_ci_builds_retried_migration') + return unless index_exists?(:ci_builds, :id, name: "index_for_ci_builds_retried_migration") remove_concurrent_index(:ci_builds, :id, name: "index_for_ci_builds_retried_migration") end @@ -21,8 +21,8 @@ class RemoveTemporaryCiBuildsIndex < ActiveRecord::Migration[4.2] # present previously so this probably shouldn't be here but it's # easier to test the drop if we have a way to create it. add_concurrent_index("ci_builds", ["id"], - name: "index_for_ci_builds_retried_migration", - where: "(retried IS NULL)", - using: :btree) + name: "index_for_ci_builds_retried_migration", + where: "(retried IS NULL)", + using: :btree) end end diff --git a/db/migrate/20170924094327_create_gcp_clusters.rb b/db/migrate/20170924094327_create_gcp_clusters.rb index 43201f75ad7..f5e6febf947 100644 --- a/db/migrate/20170924094327_create_gcp_clusters.rb +++ b/db/migrate/20170924094327_create_gcp_clusters.rb @@ -4,9 +4,9 @@ class CreateGcpClusters < ActiveRecord::Migration[4.2] def change create_table :gcp_clusters do |t| # Order columns by best align scheme - t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } - t.references :user, foreign_key: { on_delete: :nullify } - t.references :service, foreign_key: { on_delete: :nullify } + t.references :project, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade} + t.references :user, foreign_key: {on_delete: :nullify} + t.references :service, foreign_key: {on_delete: :nullify} t.integer :status t.integer :gcp_cluster_size, null: false diff --git a/db/migrate/20170927161718_create_gpg_key_subkeys.rb b/db/migrate/20170927161718_create_gpg_key_subkeys.rb index 3b5d452ee12..df167c40897 100644 --- a/db/migrate/20170927161718_create_gpg_key_subkeys.rb +++ b/db/migrate/20170927161718_create_gpg_key_subkeys.rb @@ -5,7 +5,7 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration[4.2] def up create_table :gpg_key_subkeys do |t| - t.references :gpg_key, null: false, index: true, foreign_key: { on_delete: :cascade } + t.references :gpg_key, null: false, index: true, foreign_key: {on_delete: :cascade} t.binary :keyid t.binary :fingerprint @@ -14,7 +14,7 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration[4.2] t.index :fingerprint, unique: true, length: mysql_compatible_index_length end - add_reference :gpg_signatures, :gpg_key_subkey, index: true, foreign_key: { on_delete: :nullify } + add_reference :gpg_signatures, :gpg_key_subkey, index: true, foreign_key: {on_delete: :nullify} end def down diff --git a/db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb b/db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb index cb16589e8db..d9c95999976 100644 --- a/db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb +++ b/db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb @@ -9,7 +9,7 @@ class AddCompositeIndexOnMergeRequestsMergeCommitSha < ActiveRecord::Migration[4 # The default index name is too long for PostgreSQL and would thus be # truncated. - INDEX_NAME = 'index_merge_requests_on_tp_id_and_merge_commit_sha_and_id' + INDEX_NAME = "index_merge_requests_on_tp_id_and_merge_commit_sha_and_id" COLUMNS = [:target_project_id, :merge_commit_sha, :id] diff --git a/db/migrate/20170928124105_create_fork_networks.rb b/db/migrate/20170928124105_create_fork_networks.rb index 01f623117f5..7f149b05b26 100644 --- a/db/migrate/20170928124105_create_fork_networks.rb +++ b/db/migrate/20170928124105_create_fork_networks.rb @@ -8,15 +8,15 @@ class CreateForkNetworks < ActiveRecord::Migration[4.2] def up create_table :fork_networks do |t| t.references :root_project, - references: :projects, - index: { unique: true } + references: :projects, + index: {unique: true} t.string :deleted_root_project_name end add_concurrent_foreign_key :fork_networks, :projects, - column: :root_project_id, - on_delete: :nullify + column: :root_project_id, + on_delete: :nullify end def down diff --git a/db/migrate/20170928133643_create_fork_network_members.rb b/db/migrate/20170928133643_create_fork_network_members.rb index e2a6d7b0e8a..3855bcfc4ea 100644 --- a/db/migrate/20170928133643_create_fork_network_members.rb +++ b/db/migrate/20170928133643_create_fork_network_members.rb @@ -7,14 +7,14 @@ class CreateForkNetworkMembers < ActiveRecord::Migration[4.2] def up create_table :fork_network_members do |t| - t.references :fork_network, null: false, index: true, foreign_key: { on_delete: :cascade } - t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } + t.references :fork_network, null: false, index: true, foreign_key: {on_delete: :cascade} + t.references :project, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade} t.references :forked_from_project, references: :projects end add_concurrent_foreign_key :fork_network_members, :projects, - column: :forked_from_project_id, - on_delete: :nullify + column: :forked_from_project_id, + on_delete: :nullify end def down diff --git a/db/migrate/20170929131201_populate_fork_networks.rb b/db/migrate/20170929131201_populate_fork_networks.rb index ba4f8ef2531..fc9e469222c 100644 --- a/db/migrate/20170929131201_populate_fork_networks.rb +++ b/db/migrate/20170929131201_populate_fork_networks.rb @@ -7,7 +7,7 @@ class PopulateForkNetworks < ActiveRecord::Migration[4.2] DOWNTIME = false def up - say 'Fork networks will be populated in 20171205190711 - RescheduleForkNetworkCreationCaller' + say "Fork networks will be populated in 20171205190711 - RescheduleForkNetworkCreationCaller" end def down diff --git a/db/migrate/20171006090001_create_ci_build_trace_sections.rb b/db/migrate/20171006090001_create_ci_build_trace_sections.rb index a2eca0832f2..0d963b9e849 100644 --- a/db/migrate/20171006090001_create_ci_build_trace_sections.rb +++ b/db/migrate/20171006090001_create_ci_build_trace_sections.rb @@ -5,7 +5,7 @@ class CreateCiBuildTraceSections < ActiveRecord::Migration[4.2] def change create_table :ci_build_trace_sections do |t| - t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade } + t.references :project, null: false, index: true, foreign_key: {on_delete: :cascade} t.datetime_with_timezone :date_start, null: false t.datetime_with_timezone :date_end, null: false t.integer :byte_start, limit: 8, null: false diff --git a/db/migrate/20171006090100_create_ci_build_trace_section_names.rb b/db/migrate/20171006090100_create_ci_build_trace_section_names.rb index 00a38fa59c2..c1818c6d7c3 100644 --- a/db/migrate/20171006090100_create_ci_build_trace_section_names.rb +++ b/db/migrate/20171006090100_create_ci_build_trace_section_names.rb @@ -5,7 +5,7 @@ class CreateCiBuildTraceSectionNames < ActiveRecord::Migration[4.2] def up create_table :ci_build_trace_section_names do |t| - t.references :project, null: false, foreign_key: { on_delete: :cascade } + t.references :project, null: false, foreign_key: {on_delete: :cascade} t.string :name, null: false end diff --git a/db/migrate/20171012101043_add_circuit_breaker_properties_to_application_settings.rb b/db/migrate/20171012101043_add_circuit_breaker_properties_to_application_settings.rb index 91bba07b4d7..71b33b416b6 100644 --- a/db/migrate/20171012101043_add_circuit_breaker_properties_to_application_settings.rb +++ b/db/migrate/20171012101043_add_circuit_breaker_properties_to_application_settings.rb @@ -8,20 +8,20 @@ class AddCircuitBreakerPropertiesToApplicationSettings < ActiveRecord::Migration def change add_column :application_settings, - :circuitbreaker_failure_count_threshold, - :integer, - default: 160 + :circuitbreaker_failure_count_threshold, + :integer, + default: 160 add_column :application_settings, - :circuitbreaker_failure_wait_time, - :integer, - default: 30 + :circuitbreaker_failure_wait_time, + :integer, + default: 30 add_column :application_settings, - :circuitbreaker_failure_reset_time, - :integer, - default: 1800 + :circuitbreaker_failure_reset_time, + :integer, + default: 1800 add_column :application_settings, - :circuitbreaker_storage_timeout, - :integer, - default: 30 + :circuitbreaker_storage_timeout, + :integer, + default: 30 end end diff --git a/db/migrate/20171012125712_migrate_user_authentication_token_to_personal_access_token.rb b/db/migrate/20171012125712_migrate_user_authentication_token_to_personal_access_token.rb index 305c12e31f8..50e2e13b198 100644 --- a/db/migrate/20171012125712_migrate_user_authentication_token_to_personal_access_token.rb +++ b/db/migrate/20171012125712_migrate_user_authentication_token_to_personal_access_token.rb @@ -9,7 +9,7 @@ class MigrateUserAuthenticationTokenToPersonalAccessToken < ActiveRecord::Migrat # disable_ddl_transaction! - TOKEN_NAME = 'Private Token'.freeze + TOKEN_NAME = "Private Token".freeze def up execute <<~SQL diff --git a/db/migrate/20171013094327_create_new_clusters_architectures.rb b/db/migrate/20171013094327_create_new_clusters_architectures.rb index 98f91e6130f..cd2b5a09c9e 100644 --- a/db/migrate/20171013094327_create_new_clusters_architectures.rb +++ b/db/migrate/20171013094327_create_new_clusters_architectures.rb @@ -3,7 +3,7 @@ class CreateNewClustersArchitectures < ActiveRecord::Migration[4.2] def change create_table :clusters do |t| - t.references :user, index: true, foreign_key: { on_delete: :nullify } + t.references :user, index: true, foreign_key: {on_delete: :nullify} t.integer :provider_type t.integer :platform_type @@ -17,15 +17,15 @@ class CreateNewClustersArchitectures < ActiveRecord::Migration[4.2] end create_table :cluster_projects do |t| - t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade } - t.references :cluster, null: false, index: true, foreign_key: { on_delete: :cascade } + t.references :project, null: false, index: true, foreign_key: {on_delete: :cascade} + t.references :cluster, null: false, index: true, foreign_key: {on_delete: :cascade} t.datetime_with_timezone :created_at, null: false t.datetime_with_timezone :updated_at, null: false end create_table :cluster_platforms_kubernetes do |t| - t.references :cluster, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } + t.references :cluster, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade} t.datetime_with_timezone :created_at, null: false t.datetime_with_timezone :updated_at, null: false @@ -44,7 +44,7 @@ class CreateNewClustersArchitectures < ActiveRecord::Migration[4.2] end create_table :cluster_providers_gcp do |t| - t.references :cluster, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } + t.references :cluster, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade} t.integer :status t.integer :num_nodes, null: false diff --git a/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb b/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb index 4a0cadea364..cec8a10d0c1 100644 --- a/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb +++ b/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb @@ -5,12 +5,12 @@ class AddNewCircuitbreakerSettingsToApplicationSettings < ActiveRecord::Migratio def change add_column :application_settings, - :circuitbreaker_access_retries, - :integer, - default: 3 + :circuitbreaker_access_retries, + :integer, + default: 3 add_column :application_settings, - :circuitbreaker_backoff_threshold, - :integer, - default: 80 + :circuitbreaker_backoff_threshold, + :integer, + default: 80 end end diff --git a/db/migrate/20171019141859_fix_dev_timezone_schema.rb b/db/migrate/20171019141859_fix_dev_timezone_schema.rb index 68c8b528e17..330cd7e54d9 100644 --- a/db/migrate/20171019141859_fix_dev_timezone_schema.rb +++ b/db/migrate/20171019141859_fix_dev_timezone_schema.rb @@ -9,7 +9,7 @@ class FixDevTimezoneSchema < ActiveRecord::Migration[4.2] # Set this constant to true if this migration requires downtime. DOWNTIME = false - TIMEZONE_TABLES = %i(appearances ci_group_variables ci_pipeline_schedule_variables events gpg_keys gpg_signatures project_auto_devops) + TIMEZONE_TABLES = %i[appearances ci_group_variables ci_pipeline_schedule_variables events gpg_keys gpg_signatures project_auto_devops] def up return unless Rails.env.development? || Rails.env.test? diff --git a/db/migrate/20171025110159_add_latest_merge_request_diff_id_to_merge_requests.rb b/db/migrate/20171025110159_add_latest_merge_request_diff_id_to_merge_requests.rb index 1af0cf70958..060efd0e146 100644 --- a/db/migrate/20171025110159_add_latest_merge_request_diff_id_to_merge_requests.rb +++ b/db/migrate/20171025110159_add_latest_merge_request_diff_id_to_merge_requests.rb @@ -10,8 +10,8 @@ class AddLatestMergeRequestDiffIdToMergeRequests < ActiveRecord::Migration[4.2] add_concurrent_index :merge_requests, :latest_merge_request_diff_id add_concurrent_foreign_key :merge_requests, :merge_request_diffs, - column: :latest_merge_request_diff_id, - on_delete: :nullify + column: :latest_merge_request_diff_id, + on_delete: :nullify end def down diff --git a/db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb b/db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb index 0af05f5c94a..174a6fa4396 100644 --- a/db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb +++ b/db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb @@ -5,7 +5,7 @@ class CreateClustersKubernetesHelmApps < ActiveRecord::Migration[4.2] def change create_table :clusters_applications_helm do |t| - t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade } + t.references :cluster, null: false, unique: true, foreign_key: {on_delete: :cascade} t.datetime_with_timezone :created_at, null: false t.datetime_with_timezone :updated_at, null: false diff --git a/db/migrate/20171101130535_add_gitaly_timeout_properties_to_application_settings.rb b/db/migrate/20171101130535_add_gitaly_timeout_properties_to_application_settings.rb index 6d60fdc6132..589ced6864a 100644 --- a/db/migrate/20171101130535_add_gitaly_timeout_properties_to_application_settings.rb +++ b/db/migrate/20171101130535_add_gitaly_timeout_properties_to_application_settings.rb @@ -10,17 +10,17 @@ class AddGitalyTimeoutPropertiesToApplicationSettings < ActiveRecord::Migration[ def up add_column_with_default :application_settings, - :gitaly_timeout_default, - :integer, - default: 55 + :gitaly_timeout_default, + :integer, + default: 55 add_column_with_default :application_settings, - :gitaly_timeout_medium, - :integer, - default: 30 + :gitaly_timeout_medium, + :integer, + default: 30 add_column_with_default :application_settings, - :gitaly_timeout_fast, - :integer, - default: 10 + :gitaly_timeout_fast, + :integer, + default: 10 end def down diff --git a/db/migrate/20171106101200_create_clusters_kubernetes_ingress_apps.rb b/db/migrate/20171106101200_create_clusters_kubernetes_ingress_apps.rb index 770cb94ee18..0972bdf7fb2 100644 --- a/db/migrate/20171106101200_create_clusters_kubernetes_ingress_apps.rb +++ b/db/migrate/20171106101200_create_clusters_kubernetes_ingress_apps.rb @@ -5,7 +5,7 @@ class CreateClustersKubernetesIngressApps < ActiveRecord::Migration[4.2] def change create_table :clusters_applications_ingress do |t| - t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade } + t.references :cluster, null: false, unique: true, foreign_key: {on_delete: :cascade} t.datetime_with_timezone :created_at, null: false t.datetime_with_timezone :updated_at, null: false diff --git a/db/migrate/20171106132212_issues_confidential_not_null.rb b/db/migrate/20171106132212_issues_confidential_not_null.rb index 444a38c2dc5..66c749eaeb0 100644 --- a/db/migrate/20171106132212_issues_confidential_not_null.rb +++ b/db/migrate/20171106132212_issues_confidential_not_null.rb @@ -8,11 +8,11 @@ class IssuesConfidentialNotNull < ActiveRecord::Migration[4.2] DOWNTIME = false class Issue < ActiveRecord::Base - self.table_name = 'issues' + self.table_name = "issues" end def up - Issue.where('confidential IS NULL').update_all(confidential: false) + Issue.where("confidential IS NULL").update_all(confidential: false) change_column_null :issues, :confidential, false end diff --git a/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb b/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb index 1de7d5e768e..d4d6616c3e4 100644 --- a/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb +++ b/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb @@ -12,11 +12,11 @@ class IssuesMilestoneIdForeignKey < ActiveRecord::Migration[4.2] class Issue < ActiveRecord::Base include EachBatch - self.table_name = 'issues' + self.table_name = "issues" def self.with_orphaned_milestones - where('NOT EXISTS (SELECT true FROM milestones WHERE milestones.id = issues.milestone_id)') - .where('milestone_id IS NOT NULL') + where("NOT EXISTS (SELECT true FROM milestones WHERE milestones.id = issues.milestone_id)") + .where("milestone_id IS NOT NULL") end end diff --git a/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb b/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb index b2992b1ff5d..5ddd47bf991 100644 --- a/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb +++ b/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb @@ -12,11 +12,11 @@ class IssuesUpdatedByIdForeignKey < ActiveRecord::Migration[4.2] class Issue < ActiveRecord::Base include EachBatch - self.table_name = 'issues' + self.table_name = "issues" def self.with_orphaned_updaters - where('NOT EXISTS (SELECT true FROM users WHERE users.id = issues.updated_by_id)') - .where('updated_by_id IS NOT NULL') + where("NOT EXISTS (SELECT true FROM users WHERE users.id = issues.updated_by_id)") + .where("updated_by_id IS NOT NULL") end end @@ -28,7 +28,7 @@ class IssuesUpdatedByIdForeignKey < ActiveRecord::Migration[4.2] # This index is only used for foreign keys, and those in turn will always # specify a value. As such we can add a WHERE condition to make the index # smaller. - add_concurrent_index(:issues, :updated_by_id, where: 'updated_by_id IS NOT NULL') + add_concurrent_index(:issues, :updated_by_id, where: "updated_by_id IS NOT NULL") add_concurrent_foreign_key( :issues, diff --git a/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb b/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb index 66bfb5718dc..17ea299cefa 100644 --- a/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb +++ b/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb @@ -12,22 +12,22 @@ class IssuesMovedToIdForeignKey < ActiveRecord::Migration[4.2] class Issue < ActiveRecord::Base include EachBatch - self.table_name = 'issues' + self.table_name = "issues" def self.with_orphaned_moved_to_issues if Gitlab::Database.postgresql? # Be careful to use a second table here for comparison otherwise we'll null # out all rows that don't have id == moved.to_id! - where('NOT EXISTS (SELECT true FROM issues B WHERE issues.moved_to_id = B.id)') - .where('moved_to_id IS NOT NULL') + where("NOT EXISTS (SELECT true FROM issues B WHERE issues.moved_to_id = B.id)") + .where("moved_to_id IS NOT NULL") else # MySQL doesn't allow modification of the same table in a subquery, # and using a temporary table isn't automatically guaranteed to work # due to the MySQL query optimizer. See # https://dev.mysql.com/doc/refman/5.7/en/update.html for more # details. - joins('LEFT JOIN issues AS b ON issues.moved_to_id = b.id') - .where('issues.moved_to_id IS NOT NULL AND b.id IS NULL') + joins("LEFT JOIN issues AS b ON issues.moved_to_id = b.id") + .where("issues.moved_to_id IS NOT NULL AND b.id IS NULL") end end end @@ -46,7 +46,7 @@ class IssuesMovedToIdForeignKey < ActiveRecord::Migration[4.2] # We're using a partial index here so we only index the data we actually # care about. - add_concurrent_index(:issues, :moved_to_id, where: 'moved_to_id IS NOT NULL') + add_concurrent_index(:issues, :moved_to_id, where: "moved_to_id IS NOT NULL") end def down diff --git a/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb b/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb index 58392de5e6b..ba0dab3d488 100644 --- a/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb +++ b/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb @@ -7,8 +7,8 @@ class TurnIssuesDueDateIndexToPartialIndex < ActiveRecord::Migration[4.2] # Set this constant to true if this migration requires downtime. DOWNTIME = false - NEW_INDEX_NAME = 'idx_issues_on_project_id_and_due_date_and_id_and_state_partial' - OLD_INDEX_NAME = 'index_issues_on_project_id_and_due_date_and_id_and_state' + NEW_INDEX_NAME = "idx_issues_on_project_id_and_due_date_and_id_and_state_partial" + OLD_INDEX_NAME = "index_issues_on_project_id_and_due_date_and_id_and_state" disable_ddl_transaction! @@ -16,7 +16,7 @@ class TurnIssuesDueDateIndexToPartialIndex < ActiveRecord::Migration[4.2] add_concurrent_index( :issues, [:project_id, :due_date, :id, :state], - where: 'due_date IS NOT NULL', + where: "due_date IS NOT NULL", name: NEW_INDEX_NAME ) diff --git a/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb b/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb index 4ebb6fad059..6d426fe5dee 100644 --- a/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb +++ b/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb @@ -12,11 +12,11 @@ class MergeRequestsAuthorIdForeignKey < ActiveRecord::Migration[4.2] class MergeRequest < ActiveRecord::Base include EachBatch - self.table_name = 'merge_requests' + self.table_name = "merge_requests" def self.with_orphaned_authors - where('NOT EXISTS (SELECT true FROM users WHERE merge_requests.author_id = users.id)') - .where('author_id IS NOT NULL') + where("NOT EXISTS (SELECT true FROM users WHERE merge_requests.author_id = users.id)") + .where("author_id IS NOT NULL") end end diff --git a/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb b/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb index 73c177c44f9..97136bf6c4c 100644 --- a/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb +++ b/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb @@ -12,11 +12,11 @@ class MergeRequestsAssigneeIdForeignKey < ActiveRecord::Migration[4.2] class MergeRequest < ActiveRecord::Base include EachBatch - self.table_name = 'merge_requests' + self.table_name = "merge_requests" def self.with_orphaned_assignees - where('NOT EXISTS (SELECT true FROM users WHERE merge_requests.assignee_id = users.id)') - .where('assignee_id IS NOT NULL') + where("NOT EXISTS (SELECT true FROM users WHERE merge_requests.assignee_id = users.id)") + .where("assignee_id IS NOT NULL") end end diff --git a/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb b/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb index 69f9c181c10..417294ff036 100644 --- a/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb +++ b/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb @@ -12,11 +12,11 @@ class MergeRequestsUpdatedByIdForeignKey < ActiveRecord::Migration[4.2] class MergeRequest < ActiveRecord::Base include EachBatch - self.table_name = 'merge_requests' + self.table_name = "merge_requests" def self.with_orphaned_updaters - where('NOT EXISTS (SELECT true FROM users WHERE merge_requests.updated_by_id = users.id)') - .where('updated_by_id IS NOT NULL') + where("NOT EXISTS (SELECT true FROM users WHERE merge_requests.updated_by_id = users.id)") + .where("updated_by_id IS NOT NULL") end end @@ -28,7 +28,7 @@ class MergeRequestsUpdatedByIdForeignKey < ActiveRecord::Migration[4.2] add_concurrent_index( :merge_requests, :updated_by_id, - where: 'updated_by_id IS NOT NULL' + where: "updated_by_id IS NOT NULL" ) add_concurrent_foreign_key( diff --git a/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb b/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb index ccd275d5bb4..5e5cb748e71 100644 --- a/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb +++ b/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb @@ -12,11 +12,11 @@ class MergeRequestsMergeUserIdForeignKey < ActiveRecord::Migration[4.2] class MergeRequest < ActiveRecord::Base include EachBatch - self.table_name = 'merge_requests' + self.table_name = "merge_requests" def self.with_orphaned_mergers - where('NOT EXISTS (SELECT true FROM users WHERE merge_requests.merge_user_id = users.id)') - .where('merge_user_id IS NOT NULL') + where("NOT EXISTS (SELECT true FROM users WHERE merge_requests.merge_user_id = users.id)") + .where("merge_user_id IS NOT NULL") end end @@ -28,7 +28,7 @@ class MergeRequestsMergeUserIdForeignKey < ActiveRecord::Migration[4.2] add_concurrent_index( :merge_requests, :merge_user_id, - where: 'merge_user_id IS NOT NULL' + where: "merge_user_id IS NOT NULL" ) add_concurrent_foreign_key( diff --git a/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb b/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb index 250928a6551..33c4630cdef 100644 --- a/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb +++ b/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb @@ -12,11 +12,11 @@ class MergeRequestsSourceProjectIdForeignKey < ActiveRecord::Migration[4.2] class MergeRequest < ActiveRecord::Base include EachBatch - self.table_name = 'merge_requests' + self.table_name = "merge_requests" def self.with_orphaned_source_projects - where('NOT EXISTS (SELECT true FROM projects WHERE merge_requests.source_project_id = projects.id)') - .where('source_project_id IS NOT NULL') + where("NOT EXISTS (SELECT true FROM projects WHERE merge_requests.source_project_id = projects.id)") + .where("source_project_id IS NOT NULL") end end diff --git a/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb b/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb index cafe0ce0853..b7ce5ae458d 100644 --- a/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb +++ b/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb @@ -12,11 +12,11 @@ class MergeRequestsMilestoneIdForeignKey < ActiveRecord::Migration[4.2] class MergeRequest < ActiveRecord::Base include EachBatch - self.table_name = 'merge_requests' + self.table_name = "merge_requests" def self.with_orphaned_milestones - where('NOT EXISTS (SELECT true FROM milestones WHERE merge_requests.milestone_id = milestones.id)') - .where('milestone_id IS NOT NULL') + where("NOT EXISTS (SELECT true FROM milestones WHERE merge_requests.milestone_id = milestones.id)") + .where("milestone_id IS NOT NULL") end end diff --git a/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb b/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb index 935092ce46a..39e87a77e67 100644 --- a/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb +++ b/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb @@ -6,7 +6,7 @@ class PopulateMergeRequestsLatestMergeRequestDiffIdTakeTwo < ActiveRecord::Migra BATCH_SIZE = 1_000 class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' + self.table_name = "merge_requests" include ::EachBatch end @@ -14,7 +14,7 @@ class PopulateMergeRequestsLatestMergeRequestDiffIdTakeTwo < ActiveRecord::Migra disable_ddl_transaction! def up - Gitlab::BackgroundMigration.steal('PopulateMergeRequestsLatestMergeRequestDiffId') + Gitlab::BackgroundMigration.steal("PopulateMergeRequestsLatestMergeRequestDiffId") update = ' latest_merge_request_diff_id = ( diff --git a/db/migrate/20171116135628_add_environment_scope_to_clusters.rb b/db/migrate/20171116135628_add_environment_scope_to_clusters.rb index 39bb8759cc0..9a6b8db3b83 100644 --- a/db/migrate/20171116135628_add_environment_scope_to_clusters.rb +++ b/db/migrate/20171116135628_add_environment_scope_to_clusters.rb @@ -6,7 +6,7 @@ class AddEnvironmentScopeToClusters < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - add_column_with_default(:clusters, :environment_scope, :string, default: '*') + add_column_with_default(:clusters, :environment_scope, :string, default: "*") end def down diff --git a/db/migrate/20171121135738_clean_up_from_merge_request_diffs_and_commits.rb b/db/migrate/20171121135738_clean_up_from_merge_request_diffs_and_commits.rb index 6be7b75492d..42ac8f6433e 100644 --- a/db/migrate/20171121135738_clean_up_from_merge_request_diffs_and_commits.rb +++ b/db/migrate/20171121135738_clean_up_from_merge_request_diffs_and_commits.rb @@ -4,7 +4,7 @@ class CleanUpFromMergeRequestDiffsAndCommits < ActiveRecord::Migration[4.2] DOWNTIME = false class MergeRequestDiff < ActiveRecord::Base - self.table_name = 'merge_request_diffs' + self.table_name = "merge_request_diffs" include ::EachBatch end @@ -12,12 +12,12 @@ class CleanUpFromMergeRequestDiffsAndCommits < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - Gitlab::BackgroundMigration.steal('DeserializeMergeRequestDiffsAndCommits') + Gitlab::BackgroundMigration.steal("DeserializeMergeRequestDiffsAndCommits") # The literal '--- []\n' value is created by the import process and treated # as null by the application, so we can ignore those - even if we were # migrating, it wouldn't create any rows. - literal_prefix = Gitlab::Database.postgresql? ? 'E' : '' + literal_prefix = Gitlab::Database.postgresql? ? "E" : "" non_empty = " (st_commits IS NOT NULL AND st_commits != #{literal_prefix}'--- []\n') OR @@ -25,7 +25,7 @@ class CleanUpFromMergeRequestDiffsAndCommits < ActiveRecord::Migration[4.2] ".squish MergeRequestDiff.where(non_empty).each_batch(of: 500) do |relation, index| - range = relation.pluck('MIN(id)', 'MAX(id)').first + range = relation.pluck("MIN(id)", "MAX(id)").first Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits.new.perform(*range) end diff --git a/db/migrate/20171122131600_add_new_project_guidelines_to_appearances.rb b/db/migrate/20171122131600_add_new_project_guidelines_to_appearances.rb index cbcbb5d988a..e54b37edab9 100644 --- a/db/migrate/20171122131600_add_new_project_guidelines_to_appearances.rb +++ b/db/migrate/20171122131600_add_new_project_guidelines_to_appearances.rb @@ -8,7 +8,7 @@ class AddNewProjectGuidelinesToAppearances < ActiveRecord::Migration[4.2] # new_project_guidelines_html would be missing. See # https://gitlab.com/gitlab-org/gitlab-ce/issues/41041 # We're not using Appearance#flush_redis_cache on purpose here. - Rails.cache.delete('current_appearance') + Rails.cache.delete("current_appearance") change_table :appearances do |t| t.text :new_project_guidelines diff --git a/db/migrate/20171123094802_add_circuitbreaker_check_interval_to_application_settings.rb b/db/migrate/20171123094802_add_circuitbreaker_check_interval_to_application_settings.rb index 94360c64926..35dc9edbf79 100644 --- a/db/migrate/20171123094802_add_circuitbreaker_check_interval_to_application_settings.rb +++ b/db/migrate/20171123094802_add_circuitbreaker_check_interval_to_application_settings.rb @@ -8,13 +8,13 @@ class AddCircuitbreakerCheckIntervalToApplicationSettings < ActiveRecord::Migrat def up add_column_with_default :application_settings, - :circuitbreaker_check_interval, - :integer, - default: 1 + :circuitbreaker_check_interval, + :integer, + default: 1 end def down remove_column :application_settings, - :circuitbreaker_check_interval + :circuitbreaker_check_interval end end diff --git a/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb b/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb index 67444f36e24..01797f30ac8 100644 --- a/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb +++ b/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb @@ -12,25 +12,25 @@ class PopulateMissingMergeRequestStatuses < ActiveRecord::Migration[4.2] class MergeRequest < ActiveRecord::Base include EachBatch - self.table_name = 'merge_requests' + self.table_name = "merge_requests" end def up - say 'Populating missing merge_requests.state values' + say "Populating missing merge_requests.state values" # GitLab.com has no rows where "state" is NULL, and technically this should # never happen. However it doesn't hurt to be 100% certain. MergeRequest.where(state: nil).each_batch do |batch| - batch.update_all(state: 'opened') + batch.update_all(state: "opened") end - say 'Populating missing merge_requests.merge_status values. ' \ - 'This will take a few minutes...' + say "Populating missing merge_requests.merge_status values. " \ + "This will take a few minutes..." # GitLab.com has 66 880 rows where "merge_status" is NULL, dating back all # the way to 2011. MergeRequest.where(merge_status: nil).each_batch(of: 10_000) do |batch| - batch.update_all(merge_status: 'unchecked') + batch.update_all(merge_status: "unchecked") # We want to give PostgreSQL some time to vacuum any dead tuples. In # production we see it takes roughly 1 minute for a vacuuming run to clear diff --git a/db/migrate/20171127151038_add_events_related_columns_to_merge_request_metrics.rb b/db/migrate/20171127151038_add_events_related_columns_to_merge_request_metrics.rb index 385de9dd73d..d6c00d526a9 100644 --- a/db/migrate/20171127151038_add_events_related_columns_to_merge_request_metrics.rb +++ b/db/migrate/20171127151038_add_events_related_columns_to_merge_request_metrics.rb @@ -14,12 +14,12 @@ class AddEventsRelatedColumnsToMergeRequestMetrics < ActiveRecord::Migration[4.2 add_column :merge_request_metrics, :latest_closed_at, :datetime_with_timezone add_concurrent_foreign_key :merge_request_metrics, :users, - column: :merged_by_id, - on_delete: :nullify + column: :merged_by_id, + on_delete: :nullify add_concurrent_foreign_key :merge_request_metrics, :users, - column: :latest_closed_by_id, - on_delete: :nullify + column: :latest_closed_by_id, + on_delete: :nullify end def down diff --git a/db/migrate/20171207185153_add_merge_request_state_index.rb b/db/migrate/20171207185153_add_merge_request_state_index.rb index 167470cf7fe..fda01a0718a 100644 --- a/db/migrate/20171207185153_add_merge_request_state_index.rb +++ b/db/migrate/20171207185153_add_merge_request_state_index.rb @@ -7,12 +7,12 @@ class AddMergeRequestStateIndex < ActiveRecord::Migration[4.2] def up add_concurrent_index :merge_requests, [:source_project_id, :source_branch], - where: "state = 'opened'", - name: 'index_merge_requests_on_source_project_and_branch_state_opened' + where: "state = 'opened'", + name: "index_merge_requests_on_source_project_and_branch_state_opened" end def down remove_concurrent_index_by_name :merge_requests, - 'index_merge_requests_on_source_project_and_branch_state_opened' + "index_merge_requests_on_source_project_and_branch_state_opened" end end diff --git a/db/migrate/20171212203433_create_clusters_applications_prometheus.rb b/db/migrate/20171212203433_create_clusters_applications_prometheus.rb index 6eb9fec609e..f0b0bee2354 100644 --- a/db/migrate/20171212203433_create_clusters_applications_prometheus.rb +++ b/db/migrate/20171212203433_create_clusters_applications_prometheus.rb @@ -5,7 +5,7 @@ class CreateClustersApplicationsPrometheus < ActiveRecord::Migration[4.2] def change create_table :clusters_applications_prometheus do |t| - t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade } + t.references :cluster, null: false, unique: true, foreign_key: {on_delete: :cascade} t.integer :status, null: false t.string :version, null: false diff --git a/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb b/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb index e2d7879b140..c233ec870e7 100644 --- a/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb +++ b/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb @@ -13,12 +13,12 @@ class PopulateCanPushFromDeployKeysProjects < ActiveRecord::Migration[4.2] class DeploysKeyProject < ActiveRecord::Base include EachBatch - self.table_name = 'deploy_keys_projects' + self.table_name = "deploy_keys_projects" end def up DeploysKeyProject.each_batch(of: 10_000) do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first + start_id, end_id = batch.pluck("MIN(id), MAX(id)").first if Gitlab::Database.mysql? execute <<-EOF.strip_heredoc @@ -41,7 +41,7 @@ class PopulateCanPushFromDeployKeysProjects < ActiveRecord::Migration[4.2] def down DeploysKeyProject.each_batch(of: 10_000) do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first + start_id, end_id = batch.pluck("MIN(id), MAX(id)").first if Gitlab::Database.mysql? execute <<-EOF.strip_heredoc diff --git a/db/migrate/20171216111734_clean_up_for_members.rb b/db/migrate/20171216111734_clean_up_for_members.rb index 2fefc6c7fd1..9e33a2c186e 100644 --- a/db/migrate/20171216111734_clean_up_for_members.rb +++ b/db/migrate/20171216111734_clean_up_for_members.rb @@ -12,7 +12,7 @@ class CleanUpForMembers < ActiveRecord::Migration[4.2] class Member < ActiveRecord::Base include EachBatch - self.table_name = 'members' + self.table_name = "members" end def up diff --git a/db/migrate/20171216112339_add_foreign_key_for_members.rb b/db/migrate/20171216112339_add_foreign_key_for_members.rb index 06c2c5068da..81aa305d7fb 100644 --- a/db/migrate/20171216112339_add_foreign_key_for_members.rb +++ b/db/migrate/20171216112339_add_foreign_key_for_members.rb @@ -11,8 +11,8 @@ class AddForeignKeyForMembers < ActiveRecord::Migration[4.2] def up add_concurrent_foreign_key(:members, - :users, - column: :user_id) + :users, + column: :user_id) end def down diff --git a/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb b/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb index 7543e435941..a65c842eaaf 100644 --- a/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb +++ b/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb @@ -1,7 +1,7 @@ class AddIndexOnNamespacesLowerName < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'index_on_namespaces_lower_name' + INDEX_NAME = "index_on_namespaces_lower_name" disable_ddl_transaction! diff --git a/db/migrate/20180101160629_create_prometheus_metrics.rb b/db/migrate/20180101160629_create_prometheus_metrics.rb index e3b1ed710d6..5edd93d569c 100644 --- a/db/migrate/20180101160629_create_prometheus_metrics.rb +++ b/db/migrate/20180101160629_create_prometheus_metrics.rb @@ -5,7 +5,7 @@ class CreatePrometheusMetrics < ActiveRecord::Migration[4.2] def change create_table :prometheus_metrics do |t| - t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false + t.references :project, index: true, foreign_key: {on_delete: :cascade}, null: false t.string :title, null: false t.string :query, null: false t.string :y_label diff --git a/db/migrate/20180105212544_add_commits_count_to_merge_request_diff.rb b/db/migrate/20180105212544_add_commits_count_to_merge_request_diff.rb index e27eecde906..14a67fe47e0 100644 --- a/db/migrate/20180105212544_add_commits_count_to_merge_request_diff.rb +++ b/db/migrate/20180105212544_add_commits_count_to_merge_request_diff.rb @@ -3,12 +3,12 @@ class AddCommitsCountToMergeRequestDiff < ActiveRecord::Migration[4.2] DOWNTIME = false - MIGRATION = 'AddMergeRequestDiffCommitsCount'.freeze + MIGRATION = "AddMergeRequestDiffCommitsCount".freeze BATCH_SIZE = 5000 DELAY_INTERVAL = 5.minutes.to_i class MergeRequestDiff < ActiveRecord::Base - self.table_name = 'merge_request_diffs' + self.table_name = "merge_request_diffs" include ::EachBatch end @@ -18,7 +18,7 @@ class AddCommitsCountToMergeRequestDiff < ActiveRecord::Migration[4.2] def up add_column :merge_request_diffs, :commits_count, :integer - say 'Populating the MergeRequestDiff `commits_count`' + say "Populating the MergeRequestDiff `commits_count`" queue_background_migration_jobs_by_range_at_intervals(MergeRequestDiff, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE) end diff --git a/db/migrate/20180116193854_create_lfs_file_locks.rb b/db/migrate/20180116193854_create_lfs_file_locks.rb index 2dd0e71916b..c57ff168a8f 100644 --- a/db/migrate/20180116193854_create_lfs_file_locks.rb +++ b/db/migrate/20180116193854_create_lfs_file_locks.rb @@ -7,8 +7,8 @@ class CreateLfsFileLocks < ActiveRecord::Migration[4.2] def up create_table :lfs_file_locks do |t| - t.references :project, null: false, foreign_key: { on_delete: :cascade } - t.references :user, null: false, index: true, foreign_key: { on_delete: :cascade } + t.references :project, null: false, foreign_key: {on_delete: :cascade} + t.references :user, null: false, index: true, foreign_key: {on_delete: :cascade} t.datetime :created_at, null: false t.string :path, limit: 511 end diff --git a/db/migrate/20180125214301_create_user_callouts.rb b/db/migrate/20180125214301_create_user_callouts.rb index 6eb2f932ccc..c0dbb5bbd72 100644 --- a/db/migrate/20180125214301_create_user_callouts.rb +++ b/db/migrate/20180125214301_create_user_callouts.rb @@ -8,7 +8,7 @@ class CreateUserCallouts < ActiveRecord::Migration[4.2] def change create_table :user_callouts do |t| t.integer :feature_name, null: false - t.references :user, index: true, foreign_key: { on_delete: :cascade }, null: false + t.references :user, index: true, foreign_key: {on_delete: :cascade}, null: false end add_index :user_callouts, [:user_id, :feature_name], unique: true diff --git a/db/migrate/20180201102129_add_unique_constraint_to_trending_projects_project_id.rb b/db/migrate/20180201102129_add_unique_constraint_to_trending_projects_project_id.rb index 1f2a79d36a5..3122c26db81 100644 --- a/db/migrate/20180201102129_add_unique_constraint_to_trending_projects_project_id.rb +++ b/db/migrate/20180201102129_add_unique_constraint_to_trending_projects_project_id.rb @@ -6,14 +6,14 @@ class AddUniqueConstraintToTrendingProjectsProjectId < ActiveRecord::Migration[4 disable_ddl_transaction! def up - add_concurrent_index :trending_projects, :project_id, unique: true, name: 'index_trending_projects_on_project_id_unique' - remove_concurrent_index_by_name :trending_projects, 'index_trending_projects_on_project_id' - rename_index :trending_projects, 'index_trending_projects_on_project_id_unique', 'index_trending_projects_on_project_id' + add_concurrent_index :trending_projects, :project_id, unique: true, name: "index_trending_projects_on_project_id_unique" + remove_concurrent_index_by_name :trending_projects, "index_trending_projects_on_project_id" + rename_index :trending_projects, "index_trending_projects_on_project_id_unique", "index_trending_projects_on_project_id" end def down - rename_index :trending_projects, 'index_trending_projects_on_project_id', 'index_trending_projects_on_project_id_old' + rename_index :trending_projects, "index_trending_projects_on_project_id", "index_trending_projects_on_project_id_old" add_concurrent_index :trending_projects, :project_id - remove_concurrent_index_by_name :trending_projects, 'index_trending_projects_on_project_id_old' + remove_concurrent_index_by_name :trending_projects, "index_trending_projects_on_project_id_old" end end diff --git a/db/migrate/20180201110056_add_foreign_keys_to_todos.rb b/db/migrate/20180201110056_add_foreign_keys_to_todos.rb index 6b217632a52..86e3445885f 100644 --- a/db/migrate/20180201110056_add_foreign_keys_to_todos.rb +++ b/db/migrate/20180201110056_add_foreign_keys_to_todos.rb @@ -2,7 +2,7 @@ class AddForeignKeysToTodos < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers class Todo < ActiveRecord::Base - self.table_name = 'todos' + self.table_name = "todos" include EachBatch end @@ -13,15 +13,15 @@ class AddForeignKeysToTodos < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - Todo.where('NOT EXISTS ( SELECT true FROM users WHERE id=todos.user_id )').each_batch(of: BATCH_SIZE) do |batch| + Todo.where("NOT EXISTS ( SELECT true FROM users WHERE id=todos.user_id )").each_batch(of: BATCH_SIZE) do |batch| batch.delete_all end - Todo.where('NOT EXISTS ( SELECT true FROM users WHERE id=todos.author_id )').each_batch(of: BATCH_SIZE) do |batch| + Todo.where("NOT EXISTS ( SELECT true FROM users WHERE id=todos.author_id )").each_batch(of: BATCH_SIZE) do |batch| batch.delete_all end - Todo.where('note_id IS NOT NULL AND NOT EXISTS ( SELECT true FROM notes WHERE id=todos.note_id )').each_batch(of: BATCH_SIZE) do |batch| + Todo.where("note_id IS NOT NULL AND NOT EXISTS ( SELECT true FROM notes WHERE id=todos.note_id )").each_batch(of: BATCH_SIZE) do |batch| batch.delete_all end diff --git a/db/migrate/20180201145907_migrate_remaining_issues_closed_at.rb b/db/migrate/20180201145907_migrate_remaining_issues_closed_at.rb index d398909f25b..5f1db2138e5 100644 --- a/db/migrate/20180201145907_migrate_remaining_issues_closed_at.rb +++ b/db/migrate/20180201145907_migrate_remaining_issues_closed_at.rb @@ -10,13 +10,13 @@ class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration[4.2] disable_ddl_transaction! class Issue < ActiveRecord::Base - self.table_name = 'issues' + self.table_name = "issues" include EachBatch end def up - Gitlab::BackgroundMigration.steal('CopyColumn') - Gitlab::BackgroundMigration.steal('CleanupConcurrentTypeChange') + Gitlab::BackgroundMigration.steal("CopyColumn") + Gitlab::BackgroundMigration.steal("CleanupConcurrentTypeChange") if migrate_column_type? if closed_at_for_type_change_exists? @@ -37,8 +37,8 @@ class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration[4.2] end def migrate_remaining_rows - Issue.where('closed_at_for_type_change IS NULL AND closed_at IS NOT NULL').each_batch do |batch| - batch.update_all('closed_at_for_type_change = closed_at') + Issue.where("closed_at_for_type_change IS NULL AND closed_at IS NOT NULL").each_batch do |batch| + batch.update_all("closed_at_for_type_change = closed_at") end cleanup_concurrent_column_type_change(:issues, :closed_at) @@ -47,10 +47,10 @@ class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration[4.2] def migrate_column_type? # Some environments may have already executed the previous version of this # migration, thus we don't need to migrate those environments again. - column_for('issues', 'closed_at').type == :datetime # rubocop:disable Migration/Datetime + column_for("issues", "closed_at").type == :datetime # rubocop:disable Migration/Datetime end def closed_at_for_type_change_exists? - columns('issues').any? { |col| col.name == 'closed_at_for_type_change' } + columns("issues").any? { |col| col.name == "closed_at_for_type_change" } end end diff --git a/db/migrate/20180206200543_reset_events_primary_key_sequence.rb b/db/migrate/20180206200543_reset_events_primary_key_sequence.rb index d395c5725e4..e52fad7e250 100644 --- a/db/migrate/20180206200543_reset_events_primary_key_sequence.rb +++ b/db/migrate/20180206200543_reset_events_primary_key_sequence.rb @@ -8,7 +8,7 @@ class ResetEventsPrimaryKeySequence < ActiveRecord::Migration[4.2] DOWNTIME = false class Event < ActiveRecord::Base - self.table_name = 'events' + self.table_name = "events" end def up @@ -28,7 +28,7 @@ class ResetEventsPrimaryKeySequence < ActiveRecord::Migration[4.2] end def reset_primary_key_for_mysql - amount = Event.pluck('COALESCE(MAX(id), 1)').first + amount = Event.pluck("COALESCE(MAX(id), 1)").first execute "ALTER TABLE #{Event.table_name} AUTO_INCREMENT = #{amount}" end diff --git a/db/migrate/20180208183958_schedule_populate_untracked_uploads_if_needed.rb b/db/migrate/20180208183958_schedule_populate_untracked_uploads_if_needed.rb index b69ac8f94c1..0f90e95d2c7 100644 --- a/db/migrate/20180208183958_schedule_populate_untracked_uploads_if_needed.rb +++ b/db/migrate/20180208183958_schedule_populate_untracked_uploads_if_needed.rb @@ -6,12 +6,12 @@ class SchedulePopulateUntrackedUploadsIfNeeded < ActiveRecord::Migration[4.2] DOWNTIME = false - FOLLOW_UP_MIGRATION = 'PopulateUntrackedUploads'.freeze + FOLLOW_UP_MIGRATION = "PopulateUntrackedUploads".freeze class UntrackedFile < ActiveRecord::Base include EachBatch - self.table_name = 'untracked_files_for_uploads' + self.table_name = "untracked_files_for_uploads" end def up @@ -42,6 +42,7 @@ class SchedulePopulateUntrackedUploadsIfNeeded < ActiveRecord::Migration[4.2] say "Scheduling #{FOLLOW_UP_MIGRATION} background migration jobs since there are rows in untracked_files_for_uploads." bulk_queue_background_migration_jobs_by_range( - UntrackedFile, FOLLOW_UP_MIGRATION) + UntrackedFile, FOLLOW_UP_MIGRATION + ) end end diff --git a/db/migrate/20180209115333_create_chatops_tables.rb b/db/migrate/20180209115333_create_chatops_tables.rb index 2cfb71e1007..f5af604ac1f 100644 --- a/db/migrate/20180209115333_create_chatops_tables.rb +++ b/db/migrate/20180209115333_create_chatops_tables.rb @@ -8,7 +8,7 @@ class CreateChatopsTables < ActiveRecord::Migration[4.2] def change create_table :ci_pipeline_chat_data, id: :bigserial do |t| t.integer :pipeline_id, null: false - t.references :chat_name, foreign_key: { on_delete: :cascade }, null: false + t.references :chat_name, foreign_key: {on_delete: :cascade}, null: false t.text :response_url, null: false # A pipeline can only contain one row in this table, hence this index is diff --git a/db/migrate/20180213131630_add_partial_index_to_projects_for_index_only_scans.rb b/db/migrate/20180213131630_add_partial_index_to_projects_for_index_only_scans.rb index 905915d9239..126122e2e5c 100644 --- a/db/migrate/20180213131630_add_partial_index_to_projects_for_index_only_scans.rb +++ b/db/migrate/20180213131630_add_partial_index_to_projects_for_index_only_scans.rb @@ -2,14 +2,14 @@ class AddPartialIndexToProjectsForIndexOnlyScans < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'index_projects_on_id_partial_for_visibility' + INDEX_NAME = "index_projects_on_id_partial_for_visibility" disable_ddl_transaction! # Adds a partial index to leverage index-only scans when looking up project ids def up unless index_exists?(:projects, :id, name: INDEX_NAME) - add_concurrent_index :projects, :id, name: INDEX_NAME, unique: true, where: 'visibility_level IN (10,20)' + add_concurrent_index :projects, :id, name: INDEX_NAME, unique: true, where: "visibility_level IN (10,20)" end end diff --git a/db/migrate/20180214093516_create_badges.rb b/db/migrate/20180214093516_create_badges.rb index 66e017b115a..95795b9ef12 100644 --- a/db/migrate/20180214093516_create_badges.rb +++ b/db/migrate/20180214093516_create_badges.rb @@ -5,7 +5,7 @@ class CreateBadges < ActiveRecord::Migration[4.2] create_table :badges do |t| t.string :link_url, null: false t.string :image_url, null: false - t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: true + t.references :project, index: true, foreign_key: {on_delete: :cascade}, null: true t.integer :group_id, index: true, null: true t.string :type, null: false diff --git a/db/migrate/20180214155405_create_clusters_applications_runners.rb b/db/migrate/20180214155405_create_clusters_applications_runners.rb index ce594c91890..c63efa6eb64 100644 --- a/db/migrate/20180214155405_create_clusters_applications_runners.rb +++ b/db/migrate/20180214155405_create_clusters_applications_runners.rb @@ -7,7 +7,7 @@ class CreateClustersApplicationsRunners < ActiveRecord::Migration[4.2] def up create_table :clusters_applications_runners do |t| - t.references :cluster, null: false, foreign_key: { on_delete: :cascade } + t.references :cluster, null: false, foreign_key: {on_delete: :cascade} t.references :runner, references: :ci_runners t.index :runner_id t.index :cluster_id, unique: true diff --git a/db/migrate/20180215181245_users_name_lower_index.rb b/db/migrate/20180215181245_users_name_lower_index.rb index 3b80601a727..f483e4c0acb 100644 --- a/db/migrate/20180215181245_users_name_lower_index.rb +++ b/db/migrate/20180215181245_users_name_lower_index.rb @@ -6,7 +6,7 @@ class UsersNameLowerIndex < ActiveRecord::Migration[4.2] # Set this constant to true if this migration requires downtime. DOWNTIME = false - INDEX_NAME = 'index_on_users_name_lower' + INDEX_NAME = "index_on_users_name_lower" disable_ddl_transaction! diff --git a/db/migrate/20180223120443_create_user_interacted_projects_table.rb b/db/migrate/20180223120443_create_user_interacted_projects_table.rb index 185a690ad3d..cd8c386e87a 100644 --- a/db/migrate/20180223120443_create_user_interacted_projects_table.rb +++ b/db/migrate/20180223120443_create_user_interacted_projects_table.rb @@ -3,7 +3,7 @@ class CreateUserInteractedProjectsTable < ActiveRecord::Migration[4.2] DOWNTIME = false - INDEX_NAME = 'user_interacted_projects_non_unique_index' + INDEX_NAME = "user_interacted_projects_non_unique_index" def up create_table :user_interacted_projects, id: false do |t| diff --git a/db/migrate/20180223144945_add_allow_local_requests_from_hooks_and_services_to_application_settings.rb b/db/migrate/20180223144945_add_allow_local_requests_from_hooks_and_services_to_application_settings.rb index 3bd7d6fd827..64061c01b5e 100644 --- a/db/migrate/20180223144945_add_allow_local_requests_from_hooks_and_services_to_application_settings.rb +++ b/db/migrate/20180223144945_add_allow_local_requests_from_hooks_and_services_to_application_settings.rb @@ -7,9 +7,9 @@ class AddAllowLocalRequestsFromHooksAndServicesToApplicationSettings < ActiveRec def up add_column_with_default(:application_settings, :allow_local_requests_from_hooks_and_services, - :boolean, - default: false, - allow_null: false) + :boolean, + default: false, + allow_null: false) end def down diff --git a/db/migrate/20180302152117_ensure_foreign_keys_on_clusters_applications.rb b/db/migrate/20180302152117_ensure_foreign_keys_on_clusters_applications.rb index d660c7cfd2d..766b1191bc8 100644 --- a/db/migrate/20180302152117_ensure_foreign_keys_on_clusters_applications.rb +++ b/db/migrate/20180302152117_ensure_foreign_keys_on_clusters_applications.rb @@ -12,9 +12,9 @@ class EnsureForeignKeysOnClustersApplications < ActiveRecord::Migration[4.2] def up existing = Clusters::Cluster .joins(:application_ingress) - .where('clusters.id = clusters_applications_ingress.cluster_id') + .where("clusters.id = clusters_applications_ingress.cluster_id") - Clusters::Applications::Ingress.where('NOT EXISTS (?)', existing).in_batches do |batch| + Clusters::Applications::Ingress.where("NOT EXISTS (?)", existing).in_batches do |batch| batch.delete_all end @@ -26,9 +26,9 @@ class EnsureForeignKeysOnClustersApplications < ActiveRecord::Migration[4.2] existing = Clusters::Cluster .joins(:application_prometheus) - .where('clusters.id = clusters_applications_prometheus.cluster_id') + .where("clusters.id = clusters_applications_prometheus.cluster_id") - Clusters::Applications::Ingress.where('NOT EXISTS (?)', existing).in_batches do |batch| + Clusters::Applications::Ingress.where("NOT EXISTS (?)", existing).in_batches do |batch| batch.delete_all end diff --git a/db/migrate/20180305095250_create_internal_ids_table.rb b/db/migrate/20180305095250_create_internal_ids_table.rb index 8565f5d848b..ca4f2ae8dee 100644 --- a/db/migrate/20180305095250_create_internal_ids_table.rb +++ b/db/migrate/20180305095250_create_internal_ids_table.rb @@ -5,7 +5,7 @@ class CreateInternalIdsTable < ActiveRecord::Migration[4.2] def change create_table :internal_ids, id: :bigserial do |t| - t.references :project, null: false, foreign_key: { on_delete: :cascade } + t.references :project, null: false, foreign_key: {on_delete: :cascade} t.integer :usage, null: false t.integer :last_value, null: false diff --git a/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb b/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb index 4d2ab7d757f..1f139eb0464 100644 --- a/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb +++ b/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb @@ -3,7 +3,7 @@ class AddSectionNameIdIndexOnCiBuildTraceSections < ActiveRecord::Migration[4.2] # Set this constant to true if this migration requires downtime. DOWNTIME = false - INDEX_NAME = 'index_ci_build_trace_sections_on_section_name_id' + INDEX_NAME = "index_ci_build_trace_sections_on_section_name_id" disable_ddl_transaction! diff --git a/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb b/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb index ecb06dd4312..c027a4b91f3 100644 --- a/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb +++ b/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb @@ -3,12 +3,12 @@ class RescheduleCommitsCountForMergeRequestDiff < ActiveRecord::Migration[4.2] DOWNTIME = false - MIGRATION = 'AddMergeRequestDiffCommitsCount'.freeze + MIGRATION = "AddMergeRequestDiffCommitsCount".freeze BATCH_SIZE = 5000 DELAY_INTERVAL = 5.minutes.to_i class MergeRequestDiff < ActiveRecord::Base - self.table_name = 'merge_request_diffs' + self.table_name = "merge_request_diffs" include ::EachBatch end @@ -16,12 +16,12 @@ class RescheduleCommitsCountForMergeRequestDiff < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - say 'Populating the MergeRequestDiff `commits_count` (reschedule)' + say "Populating the MergeRequestDiff `commits_count` (reschedule)" execute("SET statement_timeout TO '60s'") if Gitlab::Database.postgresql? MergeRequestDiff.where(commits_count: nil).each_batch(of: BATCH_SIZE) do |relation, index| - start_id, end_id = relation.pluck('MIN(id), MAX(id)').first + start_id, end_id = relation.pluck("MIN(id), MAX(id)").first delay = index * DELAY_INTERVAL BackgroundMigrationWorker.perform_in(delay, MIGRATION, [start_id, end_id]) diff --git a/db/migrate/20180319190020_create_deploy_tokens.rb b/db/migrate/20180319190020_create_deploy_tokens.rb index a4d797679c5..edc1cd3db3a 100644 --- a/db/migrate/20180319190020_create_deploy_tokens.rb +++ b/db/migrate/20180319190020_create_deploy_tokens.rb @@ -11,7 +11,7 @@ class CreateDeployTokens < ActiveRecord::Migration[4.2] t.datetime_with_timezone :created_at, null: false t.string :name, null: false - t.string :token, index: { unique: true }, null: false + t.string :token, index: {unique: true}, null: false t.index [:token, :expires_at, :id], where: "(revoked IS FALSE)" end diff --git a/db/migrate/20180403035759_create_project_ci_cd_settings.rb b/db/migrate/20180403035759_create_project_ci_cd_settings.rb index 00028689779..4d5a63dc8c4 100644 --- a/db/migrate/20180403035759_create_project_ci_cd_settings.rb +++ b/db/migrate/20180403035759_create_project_ci_cd_settings.rb @@ -15,7 +15,7 @@ class CreateProjectCiCdSettings < ActiveRecord::Migration[4.2] disable_statement_timeout do # This particular INSERT will take between 10 and 20 seconds. - execute 'INSERT INTO project_ci_cd_settings (project_id) SELECT id FROM projects' + execute "INSERT INTO project_ci_cd_settings (project_id) SELECT id FROM projects" # We add the index and foreign key separately so the above INSERT statement # takes as little time as possible. @@ -46,7 +46,7 @@ class CreateProjectCiCdSettings < ActiveRecord::Migration[4.2] add_project_id_foreign_key break rescue ActiveRecord::InvalidForeignKey - say 'project_ci_cd_settings contains some orphaned rows, retrying...' + say "project_ci_cd_settings contains some orphaned rows, retrying..." end end end diff --git a/db/migrate/20180406204716_add_limits_ci_build_trace_chunks_raw_data_for_mysql.rb b/db/migrate/20180406204716_add_limits_ci_build_trace_chunks_raw_data_for_mysql.rb index 0b541e94353..ad4062fbd51 100644 --- a/db/migrate/20180406204716_add_limits_ci_build_trace_chunks_raw_data_for_mysql.rb +++ b/db/migrate/20180406204716_add_limits_ci_build_trace_chunks_raw_data_for_mysql.rb @@ -1,6 +1,6 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. -require Rails.root.join('db/migrate/limits_ci_build_trace_chunks_raw_data_for_mysql') +require Rails.root.join("db/migrate/limits_ci_build_trace_chunks_raw_data_for_mysql") class AddLimitsCiBuildTraceChunksRawDataForMysql < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb b/db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb index 8de8b3bcc2e..0aa1d5715b4 100644 --- a/db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb +++ b/db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb @@ -40,10 +40,10 @@ class CreateMissingNamespaceForInternalUsers < ActiveRecord::Migration[4.2] end def create_namespace(user_id, username) - path = Uniquify.new.string(username) do |str| + path = Uniquify.new.string(username) { |str| query = "SELECT id FROM namespaces WHERE parent_id IS NULL AND path='#{str}' LIMIT 1" connection.exec_query(query).present? - end + } insert_query = "INSERT INTO namespaces(owner_id, path, name, created_at, updated_at) VALUES(#{user_id}, '#{path}', '#{path}', NOW(), NOW())" namespace_id = connection.insert(insert_query) @@ -55,7 +55,7 @@ class CreateMissingNamespaceForInternalUsers < ActiveRecord::Migration[4.2] return unless namespace_id row = connection.exec_query("SELECT id, path FROM namespaces WHERE id=#{namespace_id}").first - id, path = row.values_at('id', 'path') + id, path = row.values_at("id", "path") execute("INSERT INTO routes(source_id, source_type, path, name, created_at, updated_at) VALUES(#{id}, 'Namespace', '#{path}', '#{path}', NOW(), NOW())") end diff --git a/db/migrate/20180417090132_add_index_constraints_to_internal_id_table.rb b/db/migrate/20180417090132_add_index_constraints_to_internal_id_table.rb index ac6bb1a8cab..0b1b8966e0c 100644 --- a/db/migrate/20180417090132_add_index_constraints_to_internal_id_table.rb +++ b/db/migrate/20180417090132_add_index_constraints_to_internal_id_table.rb @@ -6,10 +6,10 @@ class AddIndexConstraintsToInternalIdTable < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - add_concurrent_index :internal_ids, [:usage, :namespace_id], unique: true, where: 'namespace_id IS NOT NULL' + add_concurrent_index :internal_ids, [:usage, :namespace_id], unique: true, where: "namespace_id IS NOT NULL" - replace_index(:internal_ids, [:usage, :project_id], name: 'index_internal_ids_on_usage_and_project_id') do - add_concurrent_index :internal_ids, [:usage, :project_id], unique: true, where: 'project_id IS NOT NULL' + replace_index(:internal_ids, [:usage, :project_id], name: "index_internal_ids_on_usage_and_project_id") do + add_concurrent_index :internal_ids, [:usage, :project_id], unique: true, where: "project_id IS NOT NULL" end add_concurrent_foreign_key :internal_ids, :namespaces, column: :namespace_id, on_delete: :cascade @@ -18,7 +18,7 @@ class AddIndexConstraintsToInternalIdTable < ActiveRecord::Migration[4.2] def down remove_concurrent_index :internal_ids, [:usage, :namespace_id] - replace_index(:internal_ids, [:usage, :project_id], name: 'index_internal_ids_on_usage_and_project_id') do + replace_index(:internal_ids, [:usage, :project_id], name: "index_internal_ids_on_usage_and_project_id") do add_concurrent_index :internal_ids, [:usage, :project_id], unique: true end diff --git a/db/migrate/20180417101040_add_tmp_stage_priority_index_to_ci_builds.rb b/db/migrate/20180417101040_add_tmp_stage_priority_index_to_ci_builds.rb index ce470884999..176bfdd744a 100644 --- a/db/migrate/20180417101040_add_tmp_stage_priority_index_to_ci_builds.rb +++ b/db/migrate/20180417101040_add_tmp_stage_priority_index_to_ci_builds.rb @@ -7,10 +7,10 @@ class AddTmpStagePriorityIndexToCiBuilds < ActiveRecord::Migration[4.2] def up add_concurrent_index(:ci_builds, [:stage_id, :stage_idx], - where: 'stage_idx IS NOT NULL', name: 'tmp_build_stage_position_index') + where: "stage_idx IS NOT NULL", name: "tmp_build_stage_position_index") end def down - remove_concurrent_index_by_name(:ci_builds, 'tmp_build_stage_position_index') + remove_concurrent_index_by_name(:ci_builds, "tmp_build_stage_position_index") end end diff --git a/db/migrate/20180420010616_cleanup_build_stage_migration.rb b/db/migrate/20180420010616_cleanup_build_stage_migration.rb index 30c0d97781d..ab31f365a55 100644 --- a/db/migrate/20180420010616_cleanup_build_stage_migration.rb +++ b/db/migrate/20180420010616_cleanup_build_stage_migration.rb @@ -2,14 +2,14 @@ class CleanupBuildStageMigration < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - TMP_INDEX = 'tmp_id_stage_partial_null_index'.freeze + TMP_INDEX = "tmp_id_stage_partial_null_index".freeze disable_ddl_transaction! class Build < ActiveRecord::Base include EachBatch - self.table_name = 'ci_builds' + self.table_name = "ci_builds" self.inheritance_column = :_type_disabled end @@ -19,7 +19,7 @@ class CleanupBuildStageMigration < ActiveRecord::Migration[4.2] # We steal from the background migrations queue to catch up with the # scheduled migrations set. # - Gitlab::BackgroundMigration.steal('MigrateBuildStage') + Gitlab::BackgroundMigration.steal("MigrateBuildStage") ## # We add temporary index, to make iteration over batches more performant. @@ -27,7 +27,7 @@ class CleanupBuildStageMigration < ActiveRecord::Migration[4.2] # migration file to make this operation idempotent. # unless index_exists_by_name?(:ci_builds, TMP_INDEX) - add_concurrent_index(:ci_builds, :id, where: 'stage_id IS NULL', name: TMP_INDEX) + add_concurrent_index(:ci_builds, :id, where: "stage_id IS NULL", name: TMP_INDEX) end ## @@ -39,8 +39,8 @@ class CleanupBuildStageMigration < ActiveRecord::Migration[4.2] # that when this migration is done we are confident that all rows are # already migrated. # - Build.where('stage_id IS NULL').each_batch(of: 50) do |batch| - range = batch.pluck('MIN(id)', 'MAX(id)').first + Build.where("stage_id IS NULL").each_batch(of: 50) do |batch| + range = batch.pluck("MIN(id)", "MAX(id)").first Gitlab::BackgroundMigration::MigrateBuildStage.new.perform(*range) end diff --git a/db/migrate/20180425075446_create_term_agreements.rb b/db/migrate/20180425075446_create_term_agreements.rb index 25182215841..123f94e66a1 100644 --- a/db/migrate/20180425075446_create_term_agreements.rb +++ b/db/migrate/20180425075446_create_term_agreements.rb @@ -9,20 +9,20 @@ class CreateTermAgreements < ActiveRecord::Migration[4.2] create_table :term_agreements do |t| t.references :term, index: true, null: false t.foreign_key :application_setting_terms, column: :term_id - t.references :user, index: true, null: false, foreign_key: { on_delete: :cascade } + t.references :user, index: true, null: false, foreign_key: {on_delete: :cascade} t.boolean :accepted, default: false, null: false t.timestamps_with_timezone null: false end add_index :term_agreements, [:user_id, :term_id], - unique: true, - name: 'term_agreements_unique_index' + unique: true, + name: "term_agreements_unique_index" end def down # rubocop:disable Migration/RemoveIndex - remove_index :term_agreements, name: 'term_agreements_unique_index' + remove_index :term_agreements, name: "term_agreements_unique_index" drop_table :term_agreements end diff --git a/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb b/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb index 7d38a15b850..0435565dae0 100644 --- a/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb +++ b/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb @@ -6,16 +6,16 @@ class AssureCommitsCountForMergeRequestDiff < ActiveRecord::Migration[4.2] disable_ddl_transaction! class MergeRequestDiff < ActiveRecord::Base - self.table_name = 'merge_request_diffs' + self.table_name = "merge_request_diffs" include ::EachBatch end def up - Gitlab::BackgroundMigration.steal('AddMergeRequestDiffCommitsCount') + Gitlab::BackgroundMigration.steal("AddMergeRequestDiffCommitsCount") MergeRequestDiff.where(commits_count: nil).each_batch(of: 50) do |batch| - range = batch.pluck('MIN(id)', 'MAX(id)').first + range = batch.pluck("MIN(id)", "MAX(id)").first Gitlab::BackgroundMigration::AddMergeRequestDiffCommitsCount.new.perform(*range) end diff --git a/db/migrate/20180425205249_add_index_constraints_to_pipeline_iid.rb b/db/migrate/20180425205249_add_index_constraints_to_pipeline_iid.rb index 8a0cb7ae4e4..2276ea0bd13 100644 --- a/db/migrate/20180425205249_add_index_constraints_to_pipeline_iid.rb +++ b/db/migrate/20180425205249_add_index_constraints_to_pipeline_iid.rb @@ -6,7 +6,7 @@ class AddIndexConstraintsToPipelineIid < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - add_concurrent_index :ci_pipelines, [:project_id, :iid], unique: true, where: 'iid IS NOT NULL' + add_concurrent_index :ci_pipelines, [:project_id, :iid], unique: true, where: "iid IS NOT NULL" end def down diff --git a/db/migrate/20180426102016_add_accepted_term_to_users.rb b/db/migrate/20180426102016_add_accepted_term_to_users.rb index 3c6665b4264..ce4b4f090da 100644 --- a/db/migrate/20180426102016_add_accepted_term_to_users.rb +++ b/db/migrate/20180426102016_add_accepted_term_to_users.rb @@ -11,7 +11,7 @@ class AddAcceptedTermToUsers < ActiveRecord::Migration[4.2] def up change_table :users do |t| t.references :accepted_term, - null: true + null: true end add_concurrent_foreign_key :users, :application_setting_terms, column: :accepted_term_id end diff --git a/db/migrate/20180502122856_create_project_mirror_data.rb b/db/migrate/20180502122856_create_project_mirror_data.rb index 8bc114afc0c..29b0ebdec23 100644 --- a/db/migrate/20180502122856_create_project_mirror_data.rb +++ b/db/migrate/20180502122856_create_project_mirror_data.rb @@ -7,7 +7,7 @@ class CreateProjectMirrorData < ActiveRecord::Migration[4.2] return if table_exists?(:project_mirror_data) create_table :project_mirror_data do |t| - t.references :project, index: true, foreign_key: { on_delete: :cascade } + t.references :project, index: true, foreign_key: {on_delete: :cascade} t.string :status t.string :jid t.text :last_error diff --git a/db/migrate/20180503131624_create_remote_mirrors.rb b/db/migrate/20180503131624_create_remote_mirrors.rb index 9f4bd463e66..49164827931 100644 --- a/db/migrate/20180503131624_create_remote_mirrors.rb +++ b/db/migrate/20180503131624_create_remote_mirrors.rb @@ -9,7 +9,7 @@ class CreateRemoteMirrors < ActiveRecord::Migration[4.2] return if table_exists?(:remote_mirrors) create_table :remote_mirrors do |t| - t.references :project, index: true, foreign_key: { on_delete: :cascade } + t.references :project, index: true, foreign_key: {on_delete: :cascade} t.string :url t.boolean :enabled, default: true t.string :update_status diff --git a/db/migrate/20180504195842_project_name_lower_index.rb b/db/migrate/20180504195842_project_name_lower_index.rb index 3fe90c3fbb1..c5b44e0bd7b 100644 --- a/db/migrate/20180504195842_project_name_lower_index.rb +++ b/db/migrate/20180504195842_project_name_lower_index.rb @@ -6,7 +6,7 @@ class ProjectNameLowerIndex < ActiveRecord::Migration[4.2] # Set this constant to true if this migration requires downtime. DOWNTIME = false - INDEX_NAME = 'index_projects_on_lower_name' + INDEX_NAME = "index_projects_on_lower_name" disable_ddl_transaction! diff --git a/db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb b/db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb index dba5d20f276..7881dd448a0 100644 --- a/db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb +++ b/db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb @@ -6,7 +6,7 @@ class AddNotNullConstraintToProjectMirrorDataForeignKey < ActiveRecord::Migratio class ProjectImportState < ActiveRecord::Base include EachBatch - self.table_name = 'project_mirror_data' + self.table_name = "project_mirror_data" end def up diff --git a/db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb b/db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb index b225354ca43..9f124d2009f 100644 --- a/db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb +++ b/db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb @@ -7,25 +7,25 @@ class AddUniqueConstraintToProjectMirrorDataProjectIdIndex < ActiveRecord::Migra def up add_concurrent_index(:project_mirror_data, - :project_id, - unique: true, - name: 'index_project_mirror_data_on_project_id_unique') + :project_id, + unique: true, + name: "index_project_mirror_data_on_project_id_unique") - remove_concurrent_index_by_name(:project_mirror_data, 'index_project_mirror_data_on_project_id') + remove_concurrent_index_by_name(:project_mirror_data, "index_project_mirror_data_on_project_id") rename_index(:project_mirror_data, - 'index_project_mirror_data_on_project_id_unique', - 'index_project_mirror_data_on_project_id') + "index_project_mirror_data_on_project_id_unique", + "index_project_mirror_data_on_project_id") end def down rename_index(:project_mirror_data, - 'index_project_mirror_data_on_project_id', - 'index_project_mirror_data_on_project_id_old') + "index_project_mirror_data_on_project_id", + "index_project_mirror_data_on_project_id_old") add_concurrent_index(:project_mirror_data, :project_id) remove_concurrent_index_by_name(:project_mirror_data, - 'index_project_mirror_data_on_project_id_old') + "index_project_mirror_data_on_project_id_old") end end diff --git a/db/migrate/20180511131058_create_clusters_applications_jupyter.rb b/db/migrate/20180511131058_create_clusters_applications_jupyter.rb index 749aeeb4792..8d75318f264 100644 --- a/db/migrate/20180511131058_create_clusters_applications_jupyter.rb +++ b/db/migrate/20180511131058_create_clusters_applications_jupyter.rb @@ -8,8 +8,8 @@ class CreateClustersApplicationsJupyter < ActiveRecord::Migration[4.2] def change create_table :clusters_applications_jupyter do |t| - t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade } - t.references :oauth_application, foreign_key: { on_delete: :nullify } + t.references :cluster, null: false, unique: true, foreign_key: {on_delete: :cascade} + t.references :oauth_application, foreign_key: {on_delete: :nullify} t.integer :status, null: false t.string :version, null: false diff --git a/db/migrate/20180515121227_create_notes_diff_files.rb b/db/migrate/20180515121227_create_notes_diff_files.rb index e50324d8599..39b2bf9113e 100644 --- a/db/migrate/20180515121227_create_notes_diff_files.rb +++ b/db/migrate/20180515121227_create_notes_diff_files.rb @@ -5,7 +5,7 @@ class CreateNotesDiffFiles < ActiveRecord::Migration[4.2] def change create_table :note_diff_files do |t| - t.references :diff_note, references: :notes, null: false, index: { unique: true } + t.references :diff_note, references: :notes, null: false, index: {unique: true} t.text :diff, null: false t.boolean :new_file, null: false t.boolean :renamed_file, null: false diff --git a/db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb b/db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb index 36f4770ff32..fc6926388bb 100644 --- a/db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb +++ b/db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb @@ -8,10 +8,10 @@ class AddNotNullConstraintsToProjectAuthorizations < ActiveRecord::Migration[4.2 if Gitlab::Database.postgresql? # One-pass version for PostgreSQL execute <<~SQL - ALTER TABLE project_authorizations - ALTER COLUMN user_id SET NOT NULL, - ALTER COLUMN project_id SET NOT NULL, - ALTER COLUMN access_level SET NOT NULL + ALTER TABLE project_authorizations + ALTER COLUMN user_id SET NOT NULL, + ALTER COLUMN project_id SET NOT NULL, + ALTER COLUMN access_level SET NOT NULL SQL else change_column_null :project_authorizations, :user_id, false @@ -24,10 +24,10 @@ class AddNotNullConstraintsToProjectAuthorizations < ActiveRecord::Migration[4.2 if Gitlab::Database.postgresql? # One-pass version for PostgreSQL execute <<~SQL - ALTER TABLE project_authorizations - ALTER COLUMN user_id DROP NOT NULL, - ALTER COLUMN project_id DROP NOT NULL, - ALTER COLUMN access_level DROP NOT NULL + ALTER TABLE project_authorizations + ALTER COLUMN user_id DROP NOT NULL, + ALTER COLUMN project_id DROP NOT NULL, + ALTER COLUMN access_level DROP NOT NULL SQL else change_column_null :project_authorizations, :user_id, true diff --git a/db/migrate/20180521171529_increase_mysql_text_limit_for_gpg_keys.rb b/db/migrate/20180521171529_increase_mysql_text_limit_for_gpg_keys.rb index 08ce8cc3094..ea657b978fe 100644 --- a/db/migrate/20180521171529_increase_mysql_text_limit_for_gpg_keys.rb +++ b/db/migrate/20180521171529_increase_mysql_text_limit_for_gpg_keys.rb @@ -1 +1 @@ -require_relative 'gpg_keys_limits_to_mysql' +require_relative "gpg_keys_limits_to_mysql" diff --git a/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb b/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb index bff4690427e..c62c3fe6c4e 100644 --- a/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb +++ b/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb @@ -7,7 +7,7 @@ class MergeRequestsTargetIdIidStatePartialIndex < ActiveRecord::Migration[4.2] # Set this constant to true if this migration requires downtime. DOWNTIME = false - INDEX_NAME = 'index_merge_requests_on_target_project_id_and_iid_opened' + INDEX_NAME = "index_merge_requests_on_target_project_id_and_iid_opened" disable_ddl_transaction! diff --git a/db/migrate/20180529093006_ensure_remote_mirror_columns.rb b/db/migrate/20180529093006_ensure_remote_mirror_columns.rb index 207e1f089fb..bfd9dcc2764 100644 --- a/db/migrate/20180529093006_ensure_remote_mirror_columns.rb +++ b/db/migrate/20180529093006_ensure_remote_mirror_columns.rb @@ -12,10 +12,10 @@ class EnsureRemoteMirrorColumns < ActiveRecord::Migration[4.2] unless column_exists?(:remote_mirrors, :only_protected_branches) add_column_with_default(:remote_mirrors, - :only_protected_branches, - :boolean, - default: false, - allow_null: false) + :only_protected_branches, + :boolean, + default: false, + allow_null: false) end end diff --git a/db/migrate/20180531185349_add_repository_languages.rb b/db/migrate/20180531185349_add_repository_languages.rb index 26a01c3bb26..0d59447a8d8 100644 --- a/db/migrate/20180531185349_add_repository_languages.rb +++ b/db/migrate/20180531185349_add_repository_languages.rb @@ -11,7 +11,7 @@ class AddRepositoryLanguages < ActiveRecord::Migration[4.2] end create_table(:repository_languages, id: false) do |t| - t.references :project, null: false, foreign_key: { on_delete: :cascade } + t.references :project, null: false, foreign_key: {on_delete: :cascade} t.references :programming_language, null: false t.float :share, null: false end diff --git a/db/migrate/20180608091413_add_group_to_todos.rb b/db/migrate/20180608091413_add_group_to_todos.rb index 7f8efd78c59..c05e2c82c64 100644 --- a/db/migrate/20180608091413_add_group_to_todos.rb +++ b/db/migrate/20180608091413_add_group_to_todos.rb @@ -6,7 +6,7 @@ class AddGroupToTodos < ActiveRecord::Migration[4.2] disable_ddl_transaction! class Todo < ActiveRecord::Base - self.table_name = 'todos' + self.table_name = "todos" include ::EachBatch end diff --git a/db/migrate/20180612103626_add_columns_for_helm_tiller_certificates.rb b/db/migrate/20180612103626_add_columns_for_helm_tiller_certificates.rb index d7273dff48e..3ca66d681eb 100644 --- a/db/migrate/20180612103626_add_columns_for_helm_tiller_certificates.rb +++ b/db/migrate/20180612103626_add_columns_for_helm_tiller_certificates.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class AddColumnsForHelmTillerCertificates < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20180625113853_create_import_export_uploads.rb b/db/migrate/20180625113853_create_import_export_uploads.rb index d76b3e8cc15..f80ab0cee95 100644 --- a/db/migrate/20180625113853_create_import_export_uploads.rb +++ b/db/migrate/20180625113853_create_import_export_uploads.rb @@ -5,7 +5,7 @@ class CreateImportExportUploads < ActiveRecord::Migration[4.2] create_table :import_export_uploads do |t| t.datetime_with_timezone :updated_at, null: false - t.references :project, index: true, foreign_key: { on_delete: :cascade }, unique: true + t.references :project, index: true, foreign_key: {on_delete: :cascade}, unique: true t.text :import_file t.text :export_file diff --git a/db/migrate/20180629153018_create_site_statistics.rb b/db/migrate/20180629153018_create_site_statistics.rb index 60a32b3b2a7..c8c129346e6 100644 --- a/db/migrate/20180629153018_create_site_statistics.rb +++ b/db/migrate/20180629153018_create_site_statistics.rb @@ -9,7 +9,7 @@ class CreateSiteStatistics < ActiveRecord::Migration[4.2] t.integer :wikis_count, default: 0, null: false end - execute('INSERT INTO site_statistics (id) VALUES(1)') + execute("INSERT INTO site_statistics (id) VALUES(1)") end def down diff --git a/db/migrate/20180702124358_remove_orphaned_routes.rb b/db/migrate/20180702124358_remove_orphaned_routes.rb index 62c15f9cd00..faa9e9da443 100644 --- a/db/migrate/20180702124358_remove_orphaned_routes.rb +++ b/db/migrate/20180702124358_remove_orphaned_routes.rb @@ -9,17 +9,17 @@ class RemoveOrphanedRoutes < ActiveRecord::Migration[4.2] disable_ddl_transaction! class Route < ActiveRecord::Base - self.table_name = 'routes' + self.table_name = "routes" include EachBatch def self.orphaned_namespace_routes - where(source_type: 'Namespace') - .where('NOT EXISTS ( SELECT 1 FROM namespaces WHERE namespaces.id = routes.source_id )') + where(source_type: "Namespace") + .where("NOT EXISTS ( SELECT 1 FROM namespaces WHERE namespaces.id = routes.source_id )") end def self.orphaned_project_routes - where(source_type: 'Project') - .where('NOT EXISTS ( SELECT 1 FROM projects WHERE projects.id = routes.source_id )') + where(source_type: "Project") + .where("NOT EXISTS ( SELECT 1 FROM projects WHERE projects.id = routes.source_id )") end end @@ -33,7 +33,7 @@ class RemoveOrphanedRoutes < ActiveRecord::Migration[4.2] # 150 orphaned namespace routes. [ Route.orphaned_project_routes, - Route.orphaned_namespace_routes + Route.orphaned_namespace_routes, ].each do |relation| relation.each_batch(of: 1_000) do |batch| batch.delete_all diff --git a/db/migrate/20180702134423_generate_missing_routes.rb b/db/migrate/20180702134423_generate_missing_routes.rb index a440bc3179c..6e4b19c8b29 100644 --- a/db/migrate/20180702134423_generate_missing_routes.rb +++ b/db/migrate/20180702134423_generate_missing_routes.rb @@ -15,17 +15,17 @@ class GenerateMissingRoutes < ActiveRecord::Migration[4.2] disable_ddl_transaction! class User < ActiveRecord::Base - self.table_name = 'users' + self.table_name = "users" end class Route < ActiveRecord::Base - self.table_name = 'routes' + self.table_name = "routes" end module Routable def build_full_path if parent && path - parent.build_full_path + '/' + path + parent.build_full_path + "/" + path else path end @@ -33,7 +33,7 @@ class GenerateMissingRoutes < ActiveRecord::Migration[4.2] def build_full_name if parent && name - parent.human_name + ' / ' + name + parent.human_name + " / " + name else name end @@ -58,25 +58,25 @@ class GenerateMissingRoutes < ActiveRecord::Migration[4.2] # The route path might already be taken. Instead of trying to generate a # new unique name on every conflict, we just append the row ID to the # route path. - path: "#{build_full_path}-#{id}" + path: "#{build_full_path}-#{id}", } end end class Project < ActiveRecord::Base - self.table_name = 'projects' + self.table_name = "projects" include EachBatch include GenerateMissingRoutes::Routable - belongs_to :namespace, class_name: 'GenerateMissingRoutes::Namespace' + belongs_to :namespace, class_name: "GenerateMissingRoutes::Namespace" has_one :route, as: :source, inverse_of: :source, - class_name: 'GenerateMissingRoutes::Route' + class_name: "GenerateMissingRoutes::Route" - alias_method :parent, :namespace + alias parent namespace alias_attribute :parent_id, :namespace_id def self.without_routes @@ -87,28 +87,28 @@ class GenerateMissingRoutes < ActiveRecord::Migration[4.2] WHERE source_type = ? AND source_id = projects.id )', - 'Project' + "Project" ) end def source_type_for_route - 'Project' + "Project" end end class Namespace < ActiveRecord::Base - self.table_name = 'namespaces' + self.table_name = "namespaces" include EachBatch include GenerateMissingRoutes::Routable - belongs_to :parent, class_name: 'GenerateMissingRoutes::Namespace' - belongs_to :owner, class_name: 'GenerateMissingRoutes::User' + belongs_to :parent, class_name: "GenerateMissingRoutes::Namespace" + belongs_to :owner, class_name: "GenerateMissingRoutes::User" has_one :route, as: :source, inverse_of: :source, - class_name: 'GenerateMissingRoutes::Route' + class_name: "GenerateMissingRoutes::Route" def self.without_routes where( @@ -118,12 +118,12 @@ class GenerateMissingRoutes < ActiveRecord::Migration[4.2] WHERE source_type = ? AND source_id = namespaces.id )', - 'Namespace' + "Namespace" ) end def source_type_for_route - 'Namespace' + "Namespace" end end diff --git a/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb b/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb index 03afbe217b5..05b7d6df2e9 100644 --- a/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb +++ b/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb @@ -7,9 +7,9 @@ class AddHideThirdPartyOffersToApplicationSettings < ActiveRecord::Migration[4.2 def up add_column_with_default(:application_settings, :hide_third_party_offers, - :boolean, - default: false, - allow_null: false) + :boolean, + default: false, + allow_null: false) end def down diff --git a/db/migrate/20180710162338_add_foreign_key_from_notification_settings_to_users.rb b/db/migrate/20180710162338_add_foreign_key_from_notification_settings_to_users.rb index 79691f2b24c..4db69503c66 100644 --- a/db/migrate/20180710162338_add_foreign_key_from_notification_settings_to_users.rb +++ b/db/migrate/20180710162338_add_foreign_key_from_notification_settings_to_users.rb @@ -2,13 +2,13 @@ class AddForeignKeyFromNotificationSettingsToUsers < ActiveRecord::Migration[4.2 include Gitlab::Database::MigrationHelpers class NotificationSetting < ActiveRecord::Base - self.table_name = 'notification_settings' + self.table_name = "notification_settings" include EachBatch end class User < ActiveRecord::Base - self.table_name = 'users' + self.table_name = "users" end DOWNTIME = false @@ -17,7 +17,7 @@ class AddForeignKeyFromNotificationSettingsToUsers < ActiveRecord::Migration[4.2 def up NotificationSetting.each_batch(of: 1000) do |batch| - batch.where('NOT EXISTS (?)', User.select(1).where('users.id = notification_settings.user_id')) + batch.where("NOT EXISTS (?)", User.select(1).where("users.id = notification_settings.user_id")) .delete_all end diff --git a/db/migrate/20180711103851_drop_duplicate_protected_tags.rb b/db/migrate/20180711103851_drop_duplicate_protected_tags.rb index 6166aa65f1f..259e01f8e19 100644 --- a/db/migrate/20180711103851_drop_duplicate_protected_tags.rb +++ b/db/migrate/20180711103851_drop_duplicate_protected_tags.rb @@ -9,13 +9,13 @@ class DropDuplicateProtectedTags < ActiveRecord::Migration[4.2] BATCH_SIZE = 1000 class Project < ActiveRecord::Base - self.table_name = 'projects' + self.table_name = "projects" include ::EachBatch end class ProtectedTag < ActiveRecord::Base - self.table_name = 'protected_tags' + self.table_name = "protected_tags" end def up @@ -23,7 +23,7 @@ class DropDuplicateProtectedTags < ActiveRecord::Migration[4.2] ids = ProtectedTag .where(project_id: projects) .group(:name, :project_id) - .select('max(id)') + .select("max(id)") tags = ProtectedTag .where(project_id: projects) diff --git a/db/migrate/20180713092803_create_user_statuses.rb b/db/migrate/20180713092803_create_user_statuses.rb index 43b96805c1e..f8260f57bc5 100644 --- a/db/migrate/20180713092803_create_user_statuses.rb +++ b/db/migrate/20180713092803_create_user_statuses.rb @@ -8,11 +8,11 @@ class CreateUserStatuses < ActiveRecord::Migration[4.2] def change create_table :user_statuses, id: false, primary_key: :user_id do |t| t.references :user, - foreign_key: { on_delete: :cascade }, - null: false, - primary_key: true + foreign_key: {on_delete: :cascade}, + null: false, + primary_key: true t.integer :cached_markdown_version, limit: 4 - t.string :emoji, null: false, default: 'speech_balloon' + t.string :emoji, null: false, default: "speech_balloon" t.string :message, limit: 100 t.string :message_html end diff --git a/db/migrate/20180717125853_remove_restricted_todos.rb b/db/migrate/20180717125853_remove_restricted_todos.rb index 1d4bbf6571e..358ee31c918 100644 --- a/db/migrate/20180717125853_remove_restricted_todos.rb +++ b/db/migrate/20180717125853_remove_restricted_todos.rb @@ -6,20 +6,20 @@ class RemoveRestrictedTodos < ActiveRecord::Migration[4.2] DOWNTIME = false disable_ddl_transaction! - MIGRATION = 'RemoveRestrictedTodos'.freeze + MIGRATION = "RemoveRestrictedTodos" BATCH_SIZE = 1000 DELAY_INTERVAL = 5.minutes.to_i class Project < ActiveRecord::Base include EachBatch - self.table_name = 'projects' + self.table_name = "projects" end def up - Project.where('EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)') + Project.where("EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)") .each_batch(of: BATCH_SIZE) do |batch, index| - range = batch.pluck('MIN(id)', 'MAX(id)').first + range = batch.pluck("MIN(id)", "MAX(id)").first BackgroundMigrationWorker.perform_in(index * DELAY_INTERVAL, MIGRATION, range) end diff --git a/db/migrate/20180718005113_add_instance_statistics_visibility_to_application_setting.rb b/db/migrate/20180718005113_add_instance_statistics_visibility_to_application_setting.rb index ed5fa58b481..0c1a8cfbfd7 100644 --- a/db/migrate/20180718005113_add_instance_statistics_visibility_to_application_setting.rb +++ b/db/migrate/20180718005113_add_instance_statistics_visibility_to_application_setting.rb @@ -9,9 +9,9 @@ class AddInstanceStatisticsVisibilityToApplicationSetting < ActiveRecord::Migrat def up add_column_with_default(:application_settings, :instance_statistics_visibility_private, - :boolean, - default: false, - allow_null: false) + :boolean, + default: false, + allow_null: false) end def down diff --git a/db/migrate/20180720023512_add_receive_max_input_size_to_application_settings.rb b/db/migrate/20180720023512_add_receive_max_input_size_to_application_settings.rb index 0cf3c78507e..2188d9bdb68 100644 --- a/db/migrate/20180720023512_add_receive_max_input_size_to_application_settings.rb +++ b/db/migrate/20180720023512_add_receive_max_input_size_to_application_settings.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. diff --git a/db/migrate/20180723135214_add_web_ide_client_side_preview_enabled_to_application_settings.rb b/db/migrate/20180723135214_add_web_ide_client_side_preview_enabled_to_application_settings.rb index 23b8e04674a..38ba44ffe2d 100644 --- a/db/migrate/20180723135214_add_web_ide_client_side_preview_enabled_to_application_settings.rb +++ b/db/migrate/20180723135214_add_web_ide_client_side_preview_enabled_to_application_settings.rb @@ -9,9 +9,9 @@ class AddWebIdeClientSidePreviewEnabledToApplicationSettings < ActiveRecord::Mig def up add_column_with_default(:application_settings, :web_ide_clientside_preview_enabled, - :boolean, - default: false, - allow_null: false) + :boolean, + default: false, + allow_null: false) end def down diff --git a/db/migrate/20180726172057_create_resource_label_events.rb b/db/migrate/20180726172057_create_resource_label_events.rb index 550e35d6f90..954d840f411 100644 --- a/db/migrate/20180726172057_create_resource_label_events.rb +++ b/db/migrate/20180726172057_create_resource_label_events.rb @@ -8,10 +8,10 @@ class CreateResourceLabelEvents < ActiveRecord::Migration[4.2] def change create_table :resource_label_events, id: :bigserial do |t| t.integer :action, null: false - t.references :issue, null: true, index: true, foreign_key: { on_delete: :cascade } - t.references :merge_request, null: true, index: true, foreign_key: { on_delete: :cascade } - t.references :label, index: true, foreign_key: { on_delete: :nullify } - t.references :user, index: true, foreign_key: { on_delete: :nullify } + t.references :issue, null: true, index: true, foreign_key: {on_delete: :cascade} + t.references :merge_request, null: true, index: true, foreign_key: {on_delete: :cascade} + t.references :label, index: true, foreign_key: {on_delete: :nullify} + t.references :user, index: true, foreign_key: {on_delete: :nullify} t.datetime_with_timezone :created_at, null: false end end diff --git a/db/migrate/20180815170510_add_partial_index_to_ci_builds_artifacts_file.rb b/db/migrate/20180815170510_add_partial_index_to_ci_builds_artifacts_file.rb index 237e6ba4559..35719eb9847 100644 --- a/db/migrate/20180815170510_add_partial_index_to_ci_builds_artifacts_file.rb +++ b/db/migrate/20180815170510_add_partial_index_to_ci_builds_artifacts_file.rb @@ -2,7 +2,7 @@ class AddPartialIndexToCiBuildsArtifactsFile < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'partial_index_ci_builds_on_id_with_legacy_artifacts'.freeze + INDEX_NAME = "partial_index_ci_builds_on_id_with_legacy_artifacts".freeze disable_ddl_transaction! diff --git a/db/migrate/20180815175440_add_index_on_list_type.rb b/db/migrate/20180815175440_add_index_on_list_type.rb index 3fe0f6b8de5..4f13675d0f4 100644 --- a/db/migrate/20180815175440_add_index_on_list_type.rb +++ b/db/migrate/20180815175440_add_index_on_list_type.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class AddIndexOnListType < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20180831164904_fix_prometheus_metric_query_limits.rb b/db/migrate/20180831164904_fix_prometheus_metric_query_limits.rb index 80c4d11a38e..0346b03788c 100644 --- a/db/migrate/20180831164904_fix_prometheus_metric_query_limits.rb +++ b/db/migrate/20180831164904_fix_prometheus_metric_query_limits.rb @@ -2,7 +2,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. -require Rails.root.join('db/migrate/prometheus_metrics_limits_to_mysql') +require Rails.root.join("db/migrate/prometheus_metrics_limits_to_mysql") class FixPrometheusMetricQueryLimits < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20180831164910_import_common_metrics.rb b/db/migrate/20180831164910_import_common_metrics.rb index f67d5f40aad..1cbf1c18317 100644 --- a/db/migrate/20180831164910_import_common_metrics.rb +++ b/db/migrate/20180831164910_import_common_metrics.rb @@ -3,7 +3,7 @@ class ImportCommonMetrics < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers - require Rails.root.join('db/importers/common_metrics_importer.rb') + require Rails.root.join("db/importers/common_metrics_importer.rb") DOWNTIME = false diff --git a/db/migrate/20180912111628_add_knative_application.rb b/db/migrate/20180912111628_add_knative_application.rb index 86d9100d2e7..e5dcc25457a 100644 --- a/db/migrate/20180912111628_add_knative_application.rb +++ b/db/migrate/20180912111628_add_knative_application.rb @@ -7,7 +7,7 @@ class AddKnativeApplication < ActiveRecord::Migration[4.2] def change create_table "clusters_applications_knative" do |t| - t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade } + t.references :cluster, null: false, unique: true, foreign_key: {on_delete: :cascade} t.datetime_with_timezone "created_at", null: false t.datetime_with_timezone "updated_at", null: false diff --git a/db/migrate/20180924141949_add_diff_max_patch_bytes_to_application_settings.rb b/db/migrate/20180924141949_add_diff_max_patch_bytes_to_application_settings.rb index 5dac5f0d100..f48d8aee134 100644 --- a/db/migrate/20180924141949_add_diff_max_patch_bytes_to_application_settings.rb +++ b/db/migrate/20180924141949_add_diff_max_patch_bytes_to_application_settings.rb @@ -13,10 +13,10 @@ class AddDiffMaxPatchBytesToApplicationSettings < ActiveRecord::Migration[4.2] def up add_column_with_default(:application_settings, - :diff_max_patch_bytes, - :integer, - default: 100.kilobytes, - allow_null: false) + :diff_max_patch_bytes, + :integer, + default: 100.kilobytes, + allow_null: false) end def down diff --git a/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb b/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb index 378fc4e5fea..3606a3af9bd 100644 --- a/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb +++ b/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb @@ -4,7 +4,7 @@ class AddPartialIndexToScheduledAt < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'partial_index_ci_builds_on_scheduled_at_with_scheduled_jobs'.freeze + INDEX_NAME = "partial_index_ci_builds_on_scheduled_at_with_scheduled_jobs" disable_ddl_transaction! diff --git a/db/migrate/20180925200829_create_user_preferences.rb b/db/migrate/20180925200829_create_user_preferences.rb index b46df8157a6..f370650ed0b 100644 --- a/db/migrate/20180925200829_create_user_preferences.rb +++ b/db/migrate/20180925200829_create_user_preferences.rb @@ -4,26 +4,26 @@ class CreateUserPreferences < ActiveRecord::Migration[4.2] DOWNTIME = false class UserPreference < ActiveRecord::Base - self.table_name = 'user_preferences' + self.table_name = "user_preferences" - NOTES_FILTERS = { all_notes: 0, comments: 1 }.freeze + NOTES_FILTERS = {all_notes: 0, comments: 1}.freeze end def change create_table :user_preferences do |t| t.references :user, - null: false, - index: { unique: true }, - foreign_key: { on_delete: :cascade } + null: false, + index: {unique: true}, + foreign_key: {on_delete: :cascade} t.integer :issue_notes_filter, - default: UserPreference::NOTES_FILTERS[:all_notes], - null: false, limit: 2 + default: UserPreference::NOTES_FILTERS[:all_notes], + null: false, limit: 2 t.integer :merge_request_notes_filter, - default: UserPreference::NOTES_FILTERS[:all_notes], - null: false, - limit: 2 + default: UserPreference::NOTES_FILTERS[:all_notes], + null: false, + limit: 2 t.timestamps_with_timezone null: false end diff --git a/db/migrate/20181002172433_remove_restricted_todos_with_cte.rb b/db/migrate/20181002172433_remove_restricted_todos_with_cte.rb index 7826c8d802e..b72756e4871 100644 --- a/db/migrate/20181002172433_remove_restricted_todos_with_cte.rb +++ b/db/migrate/20181002172433_remove_restricted_todos_with_cte.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. @@ -7,20 +8,20 @@ class RemoveRestrictedTodosWithCte < ActiveRecord::Migration[4.2] DOWNTIME = false disable_ddl_transaction! - MIGRATION = 'RemoveRestrictedTodos'.freeze + MIGRATION = "RemoveRestrictedTodos" BATCH_SIZE = 1000 DELAY_INTERVAL = 5.minutes.to_i class Project < ActiveRecord::Base include EachBatch - self.table_name = 'projects' + self.table_name = "projects" end def up - Project.where('EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)') + Project.where("EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)") .each_batch(of: BATCH_SIZE) do |batch, index| - range = batch.pluck('MIN(id)', 'MAX(id)').first + range = batch.pluck("MIN(id)", "MAX(id)").first BackgroundMigrationWorker.perform_in(index * DELAY_INTERVAL, MIGRATION, range) end diff --git a/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb b/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb index 5cd312837df..9de36880222 100644 --- a/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb +++ b/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb @@ -1,7 +1,7 @@ class ImportCommonMetricsNginxVts < ActiveRecord::Migration[5.0] include Gitlab::Database::MigrationHelpers - require Rails.root.join('db/importers/common_metrics_importer.rb') + require Rails.root.join("db/importers/common_metrics_importer.rb") DOWNTIME = false diff --git a/db/migrate/20181009190428_create_clusters_kubernetes_namespaces.rb b/db/migrate/20181009190428_create_clusters_kubernetes_namespaces.rb index 62ad6c63d0a..45955580690 100644 --- a/db/migrate/20181009190428_create_clusters_kubernetes_namespaces.rb +++ b/db/migrate/20181009190428_create_clusters_kubernetes_namespaces.rb @@ -2,13 +2,13 @@ class CreateClustersKubernetesNamespaces < ActiveRecord::Migration[4.2] DOWNTIME = false - INDEX_NAME = 'kubernetes_namespaces_cluster_and_namespace' + INDEX_NAME = "kubernetes_namespaces_cluster_and_namespace" def change create_table :clusters_kubernetes_namespaces, id: :bigserial do |t| - t.references :cluster, null: false, index: true, foreign_key: { on_delete: :cascade } - t.references :project, index: true, foreign_key: { on_delete: :nullify } - t.references :cluster_project, index: true, foreign_key: { on_delete: :nullify } + t.references :cluster, null: false, index: true, foreign_key: {on_delete: :cascade} + t.references :project, index: true, foreign_key: {on_delete: :nullify} + t.references :cluster_project, index: true, foreign_key: {on_delete: :nullify} t.timestamps_with_timezone null: false diff --git a/db/migrate/20181010235606_create_board_project_recent_visits.rb b/db/migrate/20181010235606_create_board_project_recent_visits.rb index 07bfbdda26b..5ea6bdd72c2 100644 --- a/db/migrate/20181010235606_create_board_project_recent_visits.rb +++ b/db/migrate/20181010235606_create_board_project_recent_visits.rb @@ -9,11 +9,11 @@ class CreateBoardProjectRecentVisits < ActiveRecord::Migration[4.2] create_table :board_project_recent_visits, id: :bigserial do |t| t.timestamps_with_timezone null: false - t.references :user, index: true, foreign_key: { on_delete: :cascade } - t.references :project, index: true, foreign_key: { on_delete: :cascade } - t.references :board, index: true, foreign_key: { on_delete: :cascade } + t.references :user, index: true, foreign_key: {on_delete: :cascade} + t.references :project, index: true, foreign_key: {on_delete: :cascade} + t.references :board, index: true, foreign_key: {on_delete: :cascade} end - add_index :board_project_recent_visits, [:user_id, :project_id, :board_id], unique: true, name: 'index_board_project_recent_visits_on_user_project_and_board' + add_index :board_project_recent_visits, [:user_id, :project_id, :board_id], unique: true, name: "index_board_project_recent_visits_on_user_project_and_board" end end diff --git a/db/migrate/20181014203236_create_cluster_groups.rb b/db/migrate/20181014203236_create_cluster_groups.rb index 33ae9a4a478..0e9e59d5713 100644 --- a/db/migrate/20181014203236_create_cluster_groups.rb +++ b/db/migrate/20181014203236_create_cluster_groups.rb @@ -7,7 +7,7 @@ class CreateClusterGroups < ActiveRecord::Migration[4.2] def change create_table :cluster_groups do |t| - t.references :cluster, null: false, foreign_key: { on_delete: :cascade } + t.references :cluster, null: false, foreign_key: {on_delete: :cascade} t.references :group, null: false, index: true t.index [:cluster_id, :group_id], unique: true diff --git a/db/migrate/20181016152238_create_board_group_recent_visits.rb b/db/migrate/20181016152238_create_board_group_recent_visits.rb index 9e240a5f97f..9c302fe4123 100644 --- a/db/migrate/20181016152238_create_board_group_recent_visits.rb +++ b/db/migrate/20181016152238_create_board_group_recent_visits.rb @@ -9,12 +9,12 @@ class CreateBoardGroupRecentVisits < ActiveRecord::Migration[4.2] create_table :board_group_recent_visits, id: :bigserial do |t| t.timestamps_with_timezone null: false - t.references :user, index: true, foreign_key: { on_delete: :cascade } - t.references :board, index: true, foreign_key: { on_delete: :cascade } + t.references :user, index: true, foreign_key: {on_delete: :cascade} + t.references :board, index: true, foreign_key: {on_delete: :cascade} t.references :group, references: :namespace, column: :group_id, index: true t.foreign_key :namespaces, column: :group_id, on_delete: :cascade end - add_index :board_group_recent_visits, [:user_id, :group_id, :board_id], unique: true, name: 'index_board_group_recent_visits_on_user_group_and_board' + add_index :board_group_recent_visits, [:user_id, :group_id, :board_id], unique: true, name: "index_board_group_recent_visits_on_user_group_and_board" end end diff --git a/db/migrate/20181019032400_add_shards_table.rb b/db/migrate/20181019032400_add_shards_table.rb index e31af97cc94..96e9417f550 100644 --- a/db/migrate/20181019032400_add_shards_table.rb +++ b/db/migrate/20181019032400_add_shards_table.rb @@ -5,7 +5,7 @@ class AddShardsTable < ActiveRecord::Migration[4.2] def change create_table :shards do |t| - t.string :name, null: false, index: { unique: true } + t.string :name, null: false, index: {unique: true} end end end diff --git a/db/migrate/20181019032408_add_repositories_table.rb b/db/migrate/20181019032408_add_repositories_table.rb index 2153c1c9fc6..5f8745c7e47 100644 --- a/db/migrate/20181019032408_add_repositories_table.rb +++ b/db/migrate/20181019032408_add_repositories_table.rb @@ -5,11 +5,11 @@ class AddRepositoriesTable < ActiveRecord::Migration[4.2] def change create_table :repositories, id: :bigserial do |t| - t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict } - t.string :disk_path, null: false, index: { unique: true } + t.references :shard, null: false, index: true, foreign_key: {on_delete: :restrict} + t.string :disk_path, null: false, index: {unique: true} end add_column :projects, :pool_repository_id, :bigint - add_index :projects, :pool_repository_id, where: 'pool_repository_id IS NOT NULL' + add_index :projects, :pool_repository_id, where: "pool_repository_id IS NOT NULL" end end diff --git a/db/migrate/20181023144439_add_partial_index_for_legacy_successful_deployments.rb b/db/migrate/20181023144439_add_partial_index_for_legacy_successful_deployments.rb index e90e59b57a9..1191c46d6a4 100644 --- a/db/migrate/20181023144439_add_partial_index_for_legacy_successful_deployments.rb +++ b/db/migrate/20181023144439_add_partial_index_for_legacy_successful_deployments.rb @@ -4,7 +4,7 @@ class AddPartialIndexForLegacySuccessfulDeployments < ActiveRecord::Migration[4. include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'partial_index_deployments_for_legacy_successful_deployments'.freeze + INDEX_NAME = "partial_index_deployments_for_legacy_successful_deployments" disable_ddl_transaction! diff --git a/db/migrate/20181026143227_migrate_snippets_access_level_default_value.rb b/db/migrate/20181026143227_migrate_snippets_access_level_default_value.rb index 2f4ef33b253..ef5b24f9411 100644 --- a/db/migrate/20181026143227_migrate_snippets_access_level_default_value.rb +++ b/db/migrate/20181026143227_migrate_snippets_access_level_default_value.rb @@ -14,7 +14,7 @@ class MigrateSnippetsAccessLevelDefaultValue < ActiveRecord::Migration[4.2] class ProjectFeature < ActiveRecord::Base include EachBatch - self.table_name = 'project_features' + self.table_name = "project_features" end def up diff --git a/db/migrate/20181031190559_drop_gcp_clusters_table.rb b/db/migrate/20181031190559_drop_gcp_clusters_table.rb index 597fe49f4c8..7417c7dd5e0 100644 --- a/db/migrate/20181031190559_drop_gcp_clusters_table.rb +++ b/db/migrate/20181031190559_drop_gcp_clusters_table.rb @@ -12,9 +12,9 @@ class DropGcpClustersTable < ActiveRecord::Migration[4.2] def down create_table :gcp_clusters do |t| # Order columns by best align scheme - t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } - t.references :user, foreign_key: { on_delete: :nullify } - t.references :service, foreign_key: { on_delete: :nullify } + t.references :project, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade} + t.references :user, foreign_key: {on_delete: :nullify} + t.references :service, foreign_key: {on_delete: :nullify} t.integer :status t.integer :gcp_cluster_size, null: false diff --git a/db/migrate/20181101144347_add_index_for_stuck_mr_query.rb b/db/migrate/20181101144347_add_index_for_stuck_mr_query.rb index 569eaa8b22c..9d280ce50e6 100644 --- a/db/migrate/20181101144347_add_index_for_stuck_mr_query.rb +++ b/db/migrate/20181101144347_add_index_for_stuck_mr_query.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class AddIndexForStuckMrQuery < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20181101191341_create_clusters_applications_cert_manager.rb b/db/migrate/20181101191341_create_clusters_applications_cert_manager.rb index 0b6155356d9..6e596d7fd52 100644 --- a/db/migrate/20181101191341_create_clusters_applications_cert_manager.rb +++ b/db/migrate/20181101191341_create_clusters_applications_cert_manager.rb @@ -7,7 +7,7 @@ class CreateClustersApplicationsCertManager < ActiveRecord::Migration[4.2] def change create_table :clusters_applications_cert_managers do |t| - t.references :cluster, null: false, index: false, foreign_key: { on_delete: :cascade } + t.references :cluster, null: false, index: false, foreign_key: {on_delete: :cascade} t.integer :status, null: false t.string :version, null: false t.string :email, null: false diff --git a/db/migrate/20181108091549_cleanup_environments_external_url.rb b/db/migrate/20181108091549_cleanup_environments_external_url.rb index 8439f6e55e6..7e7b2104f93 100644 --- a/db/migrate/20181108091549_cleanup_environments_external_url.rb +++ b/db/migrate/20181108091549_cleanup_environments_external_url.rb @@ -9,7 +9,7 @@ class CleanupEnvironmentsExternalUrl < ActiveRecord::Migration[4.2] def up update_column_in_batches(:environments, :external_url, nil) do |table, query| - query.where(table[:external_url].matches('javascript://%')) + query.where(table[:external_url].matches("javascript://%")) end end diff --git a/db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb b/db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb index cb01fa113eb..f4b76c48998 100644 --- a/db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb +++ b/db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb @@ -27,18 +27,18 @@ class AddIndexesToCiBuildsAndPipelines < ActiveRecord::Migration[5.0] :ci_pipelines, [:project_id, :ref, :id], { - order: { id: :desc }, - name: 'index_ci_pipelines_on_project_idandrefandiddesc' - } + order: {id: :desc}, + name: "index_ci_pipelines_on_project_idandrefandiddesc", + }, ], [ :ci_builds, [:commit_id, :artifacts_expire_at, :id], { where: "type::text = 'Ci::Build'::text AND (retried = false OR retried IS NULL) AND (name::text = ANY (ARRAY['sast'::character varying, 'dependency_scanning'::character varying, 'sast:container'::character varying, 'container_scanning'::character varying, 'dast'::character varying]::text[]))", - name: 'index_ci_builds_on_commit_id_and_artifacts_expireatandidpartial' - } - ] + name: "index_ci_builds_on_commit_id_and_artifacts_expireatandidpartial", + }, + ], ] end end diff --git a/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb b/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb index f8b46395941..51f3b663c18 100644 --- a/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb +++ b/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb @@ -8,7 +8,7 @@ class AddForeignKeyToCiPipelinesMergeRequests < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - add_concurrent_index :ci_pipelines, :merge_request_id, where: 'merge_request_id IS NOT NULL' + add_concurrent_index :ci_pipelines, :merge_request_id, where: "merge_request_id IS NOT NULL" add_concurrent_foreign_key :ci_pipelines, :merge_requests, column: :merge_request_id, on_delete: :cascade end @@ -17,6 +17,6 @@ class AddForeignKeyToCiPipelinesMergeRequests < ActiveRecord::Migration[4.2] remove_foreign_key :ci_pipelines, :merge_requests end - remove_concurrent_index :ci_pipelines, :merge_request_id, where: 'merge_request_id IS NOT NULL' + remove_concurrent_index :ci_pipelines, :merge_request_id, where: "merge_request_id IS NOT NULL" end end diff --git a/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb b/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb index a524709faf8..0d6973a9568 100644 --- a/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb +++ b/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb @@ -25,9 +25,9 @@ class AddCiBuildsPartialIndexOnProjectIdAndStatus < ActiveRecord::Migration[4.2] :ci_builds, [:project_id, :status], { - name: 'index_ci_builds_project_id_and_status_for_live_jobs_partial2', - where: "(((type)::text = 'Ci::Build'::text) AND ((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text])))" - } + name: "index_ci_builds_project_id_and_status_for_live_jobs_partial2", + where: "(((type)::text = 'Ci::Build'::text) AND ((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text])))", + }, ] end end diff --git a/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb b/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb index e4fb703e887..89b4f50398c 100644 --- a/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb +++ b/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb @@ -25,9 +25,9 @@ class RemoveRedundantCiBuildsPartialIndex < ActiveRecord::Migration[4.2] :ci_builds, [:project_id, :status], { - name: 'index_ci_builds_project_id_and_status_for_live_jobs_partial', - where: "((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text]))" - } + name: "index_ci_builds_project_id_and_status_for_live_jobs_partial", + where: "((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text]))", + }, ] end end diff --git a/db/migrate/20181122160027_create_project_repositories.rb b/db/migrate/20181122160027_create_project_repositories.rb index e42cef9b1c6..20e0064ea30 100644 --- a/db/migrate/20181122160027_create_project_repositories.rb +++ b/db/migrate/20181122160027_create_project_repositories.rb @@ -10,9 +10,9 @@ class CreateProjectRepositories < ActiveRecord::Migration[5.0] def change create_table :project_repositories, id: :bigserial do |t| - t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict } - t.string :disk_path, null: false, index: { unique: true } - t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } + t.references :shard, null: false, index: true, foreign_key: {on_delete: :restrict} + t.string :disk_path, null: false, index: {unique: true} + t.references :project, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade} end end end diff --git a/db/migrate/20181123144235_create_suggestions.rb b/db/migrate/20181123144235_create_suggestions.rb index 1723f6de7eb..369d7d226a8 100644 --- a/db/migrate/20181123144235_create_suggestions.rb +++ b/db/migrate/20181123144235_create_suggestions.rb @@ -5,7 +5,7 @@ class CreateSuggestions < ActiveRecord::Migration[5.0] def change create_table :suggestions, id: :bigserial do |t| - t.references :note, foreign_key: { on_delete: :cascade }, null: false + t.references :note, foreign_key: {on_delete: :cascade}, null: false t.integer :relative_order, null: false, limit: 2 t.boolean :applied, null: false, default: false t.string :commit_id @@ -13,7 +13,7 @@ class CreateSuggestions < ActiveRecord::Migration[5.0] t.text :to_content, null: false t.index [:note_id, :relative_order], - name: 'index_suggestions_on_note_id_and_relative_order', + name: "index_suggestions_on_note_id_and_relative_order", unique: true end end diff --git a/db/migrate/20181126150622_add_events_index_on_project_id_and_created_at.rb b/db/migrate/20181126150622_add_events_index_on_project_id_and_created_at.rb index 7e9c56957d5..54e154da4ac 100644 --- a/db/migrate/20181126150622_add_events_index_on_project_id_and_created_at.rb +++ b/db/migrate/20181126150622_add_events_index_on_project_id_and_created_at.rb @@ -25,8 +25,8 @@ class AddEventsIndexOnProjectIdAndCreatedAt < ActiveRecord::Migration[5.0] :events, [:project_id, :created_at], { - name: 'index_events_on_project_id_and_created_at' - } + name: "index_events_on_project_id_and_created_at", + }, ] end end diff --git a/db/migrate/20181126153547_remove_notes_index_on_updated_at.rb b/db/migrate/20181126153547_remove_notes_index_on_updated_at.rb index d7ca46b50e4..18f17f636c1 100644 --- a/db/migrate/20181126153547_remove_notes_index_on_updated_at.rb +++ b/db/migrate/20181126153547_remove_notes_index_on_updated_at.rb @@ -25,8 +25,8 @@ class RemoveNotesIndexOnUpdatedAt < ActiveRecord::Migration[5.0] :notes, [:updated_at], { - name: 'index_notes_on_updated_at' - } + name: "index_notes_on_updated_at", + }, ] end end diff --git a/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb b/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb index f90aca008e5..139a4748706 100644 --- a/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb +++ b/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb @@ -8,7 +8,7 @@ class AddIndexToCiBuildsTokenEncrypted < ActiveRecord::Migration[5.0] disable_ddl_transaction! def up - add_concurrent_index :ci_builds, :token_encrypted, unique: true, where: 'token_encrypted IS NOT NULL' + add_concurrent_index :ci_builds, :token_encrypted, unique: true, where: "token_encrypted IS NOT NULL" end def down diff --git a/db/migrate/20181205171941_create_project_daily_statistics.rb b/db/migrate/20181205171941_create_project_daily_statistics.rb index c9e2a1e1aa7..5f23d34b3eb 100644 --- a/db/migrate/20181205171941_create_project_daily_statistics.rb +++ b/db/migrate/20181205171941_create_project_daily_statistics.rb @@ -11,7 +11,7 @@ class CreateProjectDailyStatistics < ActiveRecord::Migration[5.0] t.integer :fetch_count, null: false t.date :date - t.index [:project_id, :date], unique: true, order: { date: :desc } + t.index [:project_id, :date], unique: true, order: {date: :desc} t.foreign_key :projects, on_delete: :cascade end end diff --git a/db/migrate/20181228175414_create_releases_link_table.rb b/db/migrate/20181228175414_create_releases_link_table.rb index 03558202137..1c4d723fdcb 100644 --- a/db/migrate/20181228175414_create_releases_link_table.rb +++ b/db/migrate/20181228175414_create_releases_link_table.rb @@ -7,7 +7,7 @@ class CreateReleasesLinkTable < ActiveRecord::Migration[5.0] def change create_table :release_links, id: :bigserial do |t| - t.references :release, null: false, index: false, foreign_key: { on_delete: :cascade } + t.references :release, null: false, index: false, foreign_key: {on_delete: :cascade} t.string :url, null: false t.string :name, null: false t.timestamps_with_timezone null: false diff --git a/db/migrate/20190104182041_cleanup_legacy_artifact_migration.rb b/db/migrate/20190104182041_cleanup_legacy_artifact_migration.rb index 11659846a06..02f6a9fe44f 100644 --- a/db/migrate/20190104182041_cleanup_legacy_artifact_migration.rb +++ b/db/migrate/20190104182041_cleanup_legacy_artifact_migration.rb @@ -10,19 +10,19 @@ class CleanupLegacyArtifactMigration < ActiveRecord::Migration[5.0] class Build < ActiveRecord::Base include EachBatch - self.table_name = 'ci_builds' + self.table_name = "ci_builds" self.inheritance_column = :_type_disabled scope :with_legacy_artifacts, -> { where("artifacts_file <> ''") } end def up - Gitlab::BackgroundMigration.steal('MigrateLegacyArtifacts') + Gitlab::BackgroundMigration.steal("MigrateLegacyArtifacts") CleanupLegacyArtifactMigration::Build .with_legacy_artifacts .each_batch(of: 100) do |batch| - range = batch.pluck('MIN(id)', 'MAX(id)').first + range = batch.pluck("MIN(id)", "MAX(id)").first Gitlab::BackgroundMigration::MigrateLegacyArtifacts.new.perform(*range) end diff --git a/db/migrate/20190108192941_remove_partial_index_from_ci_builds_artifacts_file.rb b/db/migrate/20190108192941_remove_partial_index_from_ci_builds_artifacts_file.rb index 073faf721ae..14366b0743c 100644 --- a/db/migrate/20190108192941_remove_partial_index_from_ci_builds_artifacts_file.rb +++ b/db/migrate/20190108192941_remove_partial_index_from_ci_builds_artifacts_file.rb @@ -4,7 +4,7 @@ class RemovePartialIndexFromCiBuildsArtifactsFile < ActiveRecord::Migration[5.0] include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'partial_index_ci_builds_on_id_with_legacy_artifacts'.freeze + INDEX_NAME = "partial_index_ci_builds_on_id_with_legacy_artifacts" disable_ddl_transaction! diff --git a/db/migrate/20190206193120_add_index_to_tags.rb b/db/migrate/20190206193120_add_index_to_tags.rb index 5257ebba003..044e50d2d61 100644 --- a/db/migrate/20190206193120_add_index_to_tags.rb +++ b/db/migrate/20190206193120_add_index_to_tags.rb @@ -4,12 +4,12 @@ class AddIndexToTags < ActiveRecord::Migration[5.0] include Gitlab::Database::MigrationHelpers DOWNTIME = false - INDEX_NAME = 'index_tags_on_name_trigram' + INDEX_NAME = "index_tags_on_name_trigram" disable_ddl_transaction! def up - add_concurrent_index :tags, :name, name: INDEX_NAME, using: :gin, opclasses: { name: :gin_trgm_ops } + add_concurrent_index :tags, :name, name: INDEX_NAME, using: :gin, opclasses: {name: :gin_trgm_ops} end def down diff --git a/db/migrate/limits_to_mysql.rb b/db/migrate/limits_to_mysql.rb index 33cb19aff9e..67c93fa6a18 100644 --- a/db/migrate/limits_to_mysql.rb +++ b/db/migrate/limits_to_mysql.rb @@ -1,6 +1,6 @@ class LimitsToMysql < ActiveRecord::Migration[4.2] def up - return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/ + return unless ActiveRecord::Base.configurations[Rails.env]["adapter"] =~ /^mysql/ change_column :snippets, :content, :text, limit: 2147483647 change_column :notes, :st_diff, :text, limit: 2147483647 diff --git a/db/optional_migrations/composite_primary_keys.rb b/db/optional_migrations/composite_primary_keys.rb index e0bb0312a35..e3dc0799a96 100644 --- a/db/optional_migrations/composite_primary_keys.rb +++ b/db/optional_migrations/composite_primary_keys.rb @@ -15,13 +15,13 @@ class CompositePrimaryKeysMigration < ActiveRecord::Migration[4.2] Index = Struct.new(:table, :name, :columns) TABLES = [ - Index.new(:issue_assignees, 'index_issue_assignees_on_issue_id_and_user_id', %i(issue_id user_id)), - Index.new(:user_interacted_projects, 'index_user_interacted_projects_on_project_id_and_user_id', %i(project_id user_id)), - Index.new(:merge_request_diff_files, 'index_merge_request_diff_files_on_mr_diff_id_and_order', %i(merge_request_diff_id relative_order)), - Index.new(:merge_request_diff_commits, 'index_merge_request_diff_commits_on_mr_diff_id_and_order', %i(merge_request_diff_id relative_order)), - Index.new(:project_authorizations, 'index_project_authorizations_on_user_id_project_id_access_level', %i(user_id project_id access_level)), - Index.new(:push_event_payloads, 'index_push_event_payloads_on_event_id', %i(event_id)), - Index.new(:schema_migrations, 'unique_schema_migrations', %(version)) + Index.new(:issue_assignees, "index_issue_assignees_on_issue_id_and_user_id", %i[issue_id user_id]), + Index.new(:user_interacted_projects, "index_user_interacted_projects_on_project_id_and_user_id", %i[project_id user_id]), + Index.new(:merge_request_diff_files, "index_merge_request_diff_files_on_mr_diff_id_and_order", %i[merge_request_diff_id relative_order]), + Index.new(:merge_request_diff_commits, "index_merge_request_diff_commits_on_mr_diff_id_and_order", %i[merge_request_diff_id relative_order]), + Index.new(:project_authorizations, "index_project_authorizations_on_user_id_project_id_access_level", %i[user_id project_id access_level]), + Index.new(:push_event_payloads, "index_push_event_payloads_on_event_id", %i[event_id]), + Index.new(:schema_migrations, "unique_schema_migrations", %(version)), ].freeze disable_ddl_transaction! diff --git a/db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb b/db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb index 099814d7556..89c7fa660da 100644 --- a/db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb +++ b/db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb @@ -14,6 +14,6 @@ class ChangePersonalAccessTokensDefaultBackToEmptyArray < ActiveRecord::Migratio end def down - change_column_default :personal_access_tokens, :scopes, ['api'].to_yaml + change_column_default :personal_access_tokens, :scopes, ["api"].to_yaml end end diff --git a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb index 6d9c7e4ed72..c6262088c98 100644 --- a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb +++ b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb @@ -28,9 +28,9 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration[4.2] break if to_update.rows.count == 0 # row[0] is projects.id, row[1] is namespaces.visibility_level - updates = to_update.rows.each_with_object(Hash.new {|h, k| h[k] = [] }) do |row, obj| + updates = to_update.rows.each_with_object(Hash.new {|h, k| h[k] = [] }) { |row, obj| obj[row[1]] << row[0] - end + } updates.each do |visibility_level, project_ids| updater = Arel::UpdateManager.new diff --git a/db/post_migrate/20161221153951_rename_reserved_project_names.rb b/db/post_migrate/20161221153951_rename_reserved_project_names.rb index 32579256299..fd1e3b4fe3b 100644 --- a/db/post_migrate/20161221153951_rename_reserved_project_names.rb +++ b/db/post_migrate/20161221153951_rename_reserved_project_names.rb @@ -5,7 +5,7 @@ class RenameReservedProjectNames < ActiveRecord::Migration[4.2] THREAD_COUNT = 8 - KNOWN_PATHS = %w(.well-known + KNOWN_PATHS = %w[.well-known all blame blob @@ -34,13 +34,13 @@ class RenameReservedProjectNames < ActiveRecord::Migration[4.2] unsubscribes update users - wikis).freeze + wikis].freeze def up queues = Array.new(THREAD_COUNT) { Queue.new } start = false - threads = Array.new(THREAD_COUNT) do |index| + threads = Array.new(THREAD_COUNT) { |index| Thread.new do queue = queues[index] @@ -49,7 +49,7 @@ class RenameReservedProjectNames < ActiveRecord::Migration[4.2] rename_projects(queue.pop) until queue.empty? end - end + } enum = queues.each @@ -78,8 +78,8 @@ class RenameReservedProjectNames < ActiveRecord::Migration[4.2] def reserved_projects Project.unscoped .includes(:namespace) - .where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)') - .where('projects.path' => KNOWN_PATHS) + .where("EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)") + .where("projects.path" => KNOWN_PATHS) end def route_exists?(full_path) diff --git a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb index f567accb051..f0ce174cb42 100644 --- a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb +++ b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb @@ -17,9 +17,9 @@ class RequeuePendingDeleteProjects < ActiveRecord::Migration[4.2] break if ids.rows.count.zero? - args = ids.map { |id| [id['id'], admin.id, {}] } + args = ids.map { |id| [id["id"], admin.id, {}] } - Sidekiq::Client.push_bulk('class' => "ProjectDestroyWorker", 'args' => args) + Sidekiq::Client.push_bulk("class" => "ProjectDestroyWorker", "args" => args) @offset += 1 end diff --git a/db/post_migrate/20170106142508_fill_authorized_projects.rb b/db/post_migrate/20170106142508_fill_authorized_projects.rb index 1f1dd0f47f0..5c750ed5e1f 100644 --- a/db/post_migrate/20170106142508_fill_authorized_projects.rb +++ b/db/post_migrate/20170106142508_fill_authorized_projects.rb @@ -5,7 +5,7 @@ class FillAuthorizedProjects < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers class User < ActiveRecord::Base - self.table_name = 'users' + self.table_name = "users" end # Set this constant to true if this migration requires downtime. @@ -16,12 +16,12 @@ class FillAuthorizedProjects < ActiveRecord::Migration[4.2] def up relation = User.select(:id) - .where('authorized_projects_populated IS NOT TRUE') + .where("authorized_projects_populated IS NOT TRUE") relation.find_in_batches(batch_size: 1_000) do |rows| args = rows.map { |row| [row.id] } - Sidekiq::Client.push_bulk('class' => 'AuthorizedProjectsWorker', 'args' => args) + Sidekiq::Client.push_bulk("class" => "AuthorizedProjectsWorker", "args" => args) end end diff --git a/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb b/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb index f221dac8e20..8383ed66b51 100644 --- a/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb +++ b/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb @@ -9,7 +9,7 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration[4.2] Gitlab::Database.with_connection_pool(2) do |pool| threads = [] - threads << Thread.new do + threads << Thread.new { pool.with_connection do |connection| connection.execute <<-SQL.strip_heredoc DELETE FROM services @@ -18,9 +18,9 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration[4.2] AND properties = '{"notify_only_broken_builds":true}'; SQL end - end + } - threads << Thread.new do + threads << Thread.new { pool.with_connection do |connection| connection.execute <<-SQL.strip_heredoc DELETE FROM services @@ -29,7 +29,7 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration[4.2] AND properties = '{"notify_only_broken_pipelines":true}'; SQL end - end + } threads.each(&:join) end diff --git a/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb b/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb index 81ac4cf1373..fdd14195104 100644 --- a/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb +++ b/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb @@ -7,10 +7,10 @@ class ValidateForeignKeysOnOauthOpenidRequests < ActiveRecord::Migration[4.2] def up if Gitlab::Database.postgresql? - execute %q{ + execute ' ALTER TABLE "oauth_openid_requests" VALIDATE CONSTRAINT "fk_oauth_openid_requests_oauth_access_grants_access_grant_id"; - } + ' end end diff --git a/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb b/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb index c2d28d79491..df29b7764b4 100644 --- a/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb +++ b/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb @@ -7,7 +7,7 @@ class MigrateBuildEventsToPipelineEvents < ActiveRecord::Migration[4.2] Gitlab::Database.with_connection_pool(2) do |pool| threads = [] - threads << Thread.new do + threads << Thread.new { pool.with_connection do |connection| Thread.current[:foreign_key_connection] = connection @@ -23,15 +23,15 @@ class MigrateBuildEventsToPipelineEvents < ActiveRecord::Migration[4.2] AND build_events = #{true_value}; SQL end - end + } - threads << Thread.new do + threads << Thread.new { pool.with_connection do |connection| Thread.current[:foreign_key_connection] = connection execute(update_pipeline_services_sql) end - end + } threads.each(&:join) end diff --git a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb index 85c97e3687e..9e6c79c8389 100644 --- a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb +++ b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb @@ -3,7 +3,7 @@ class RenameMoreReservedProjectNames < ActiveRecord::Migration[4.2] DOWNTIME = false - KNOWN_PATHS = %w(artifacts graphs refs badges).freeze + KNOWN_PATHS = %w[artifacts graphs refs badges].freeze def up reserved_projects.each_slice(100) do |slice| @@ -20,8 +20,8 @@ class RenameMoreReservedProjectNames < ActiveRecord::Migration[4.2] def reserved_projects Project.unscoped .includes(:namespace) - .where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)') - .where('projects.path' => KNOWN_PATHS) + .where("EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)") + .where("projects.path" => KNOWN_PATHS) end def route_exists?(full_path) diff --git a/db/post_migrate/20170317162059_update_upload_paths_to_system.rb b/db/post_migrate/20170317162059_update_upload_paths_to_system.rb index 99cdca465e2..912b3278a97 100644 --- a/db/post_migrate/20170317162059_update_upload_paths_to_system.rb +++ b/db/post_migrate/20170317162059_update_upload_paths_to_system.rb @@ -5,7 +5,7 @@ class UpdateUploadPathsToSystem < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - AFFECTED_MODELS = %w(User Project Note Namespace Appearance) + AFFECTED_MODELS = %w[User Project Note Namespace Appearance] disable_ddl_transaction! diff --git a/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb b/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb index 61a5c364b2f..72349132e4c 100644 --- a/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb +++ b/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb @@ -5,7 +5,7 @@ class MigrateUserActivitiesToUsersLastActivityOn < ActiveRecord::Migration[4.2] disable_ddl_transaction! DOWNTIME = false - USER_ACTIVITY_SET_KEY = 'user/activities'.freeze + USER_ACTIVITY_SET_KEY = "user/activities".freeze ACTIVITIES_PER_PAGE = 100 TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED = Time.utc(2016, 12, 1) diff --git a/db/post_migrate/20170406111121_clean_upload_symlinks.rb b/db/post_migrate/20170406111121_clean_upload_symlinks.rb index 5fec00aa198..1915d823b38 100644 --- a/db/post_migrate/20170406111121_clean_upload_symlinks.rb +++ b/db/post_migrate/20170406111121_clean_upload_symlinks.rb @@ -6,7 +6,7 @@ class CleanUploadSymlinks < ActiveRecord::Migration[4.2] disable_ddl_transaction! DOWNTIME = false - DIRECTORIES_TO_MOVE = %w(user project note group appearance) + DIRECTORIES_TO_MOVE = %w[user project note group appearance] def up return unless file_storage? diff --git a/db/post_migrate/20170408033905_remove_old_cache_directories.rb b/db/post_migrate/20170408033905_remove_old_cache_directories.rb index 22bc5b9db7b..d96910dca89 100644 --- a/db/post_migrate/20170408033905_remove_old_cache_directories.rb +++ b/db/post_migrate/20170408033905_remove_old_cache_directories.rb @@ -13,7 +13,7 @@ class RemoveOldCacheDirectories < ActiveRecord::Migration[4.2] def up # FileUploader cache. - FileUtils.rm_rf(Dir[Rails.root.join('public', 'uploads', 'tmp', '*')]) + FileUtils.rm_rf(Dir[Rails.root.join("public", "uploads", "tmp", "*")]) end def down diff --git a/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb b/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb index 9d515aca8b4..6023dac9050 100644 --- a/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb +++ b/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb @@ -23,7 +23,7 @@ class DropCiTriggerSchedulesTable < ActiveRecord::Migration[4.2] t.boolean "active" end - add_index "ci_trigger_schedules", %w(active next_run_at), name: "index_ci_trigger_schedules_on_active_and_next_run_at", using: :btree + add_index "ci_trigger_schedules", %w[active next_run_at], name: "index_ci_trigger_schedules_on_active_and_next_run_at", using: :btree add_index "ci_trigger_schedules", ["project_id"], name: "index_ci_trigger_schedules_on_project_id", using: :btree add_index "ci_trigger_schedules", ["next_run_at"], name: "index_ci_trigger_schedules_on_next_run_at" diff --git a/db/post_migrate/20170502101023_cleanup_namespaceless_pending_delete_projects.rb b/db/post_migrate/20170502101023_cleanup_namespaceless_pending_delete_projects.rb index c018d30c175..3ecfd552039 100644 --- a/db/post_migrate/20170502101023_cleanup_namespaceless_pending_delete_projects.rb +++ b/db/post_migrate/20170502101023_cleanup_namespaceless_pending_delete_projects.rb @@ -30,7 +30,7 @@ class CleanupNamespacelessPendingDeleteProjects < ActiveRecord::Migration[4.2] private def pending_delete_batch - connection.exec_query(find_batch).map { |row| row['id'].to_i } + connection.exec_query(find_batch).map { |row| row["id"].to_i } end BATCH_SIZE = 5000 diff --git a/db/post_migrate/20170503004427_update_retried_for_ci_build.rb b/db/post_migrate/20170503004427_update_retried_for_ci_build.rb index 596f8593308..a296d951575 100644 --- a/db/post_migrate/20170503004427_update_retried_for_ci_build.rb +++ b/db/post_migrate/20170503004427_update_retried_for_ci_build.rb @@ -56,14 +56,14 @@ class UpdateRetriedForCiBuild < ActiveRecord::Migration[4.2] def with_temporary_partial_index if Gitlab::Database.postgresql? unless index_exists?(:ci_builds, :id, name: :index_for_ci_builds_retried_migration) - execute 'CREATE INDEX CONCURRENTLY index_for_ci_builds_retried_migration ON ci_builds (id) WHERE retried IS NULL;' + execute "CREATE INDEX CONCURRENTLY index_for_ci_builds_retried_migration ON ci_builds (id) WHERE retried IS NULL;" end end yield if Gitlab::Database.postgresql? && index_exists?(:ci_builds, :id, name: :index_for_ci_builds_retried_migration) - execute 'DROP INDEX CONCURRENTLY index_for_ci_builds_retried_migration' + execute "DROP INDEX CONCURRENTLY index_for_ci_builds_retried_migration" end end end diff --git a/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb b/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb index 6e7365f4c56..47e5ae893bb 100644 --- a/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb +++ b/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb @@ -12,7 +12,7 @@ class AddHeadPipelineForEachMergeRequest < ActiveRecord::Migration[4.2] disable_statement_timeout do head_id = pipelines - .project(Arel::Nodes::NamedFunction.new('max', [pipelines[:id]])) + .project(Arel::Nodes::NamedFunction.new("max", [pipelines[:id]])) .from(pipelines) .where(pipelines[:ref].eq(merge_requests[:source_branch])) .where(pipelines[:project_id].eq(merge_requests[:source_project_id])) diff --git a/db/post_migrate/20170510101043_add_foreign_key_on_pipeline_schedule_owner.rb b/db/post_migrate/20170510101043_add_foreign_key_on_pipeline_schedule_owner.rb index 85586aecd54..3dd87df9d63 100644 --- a/db/post_migrate/20170510101043_add_foreign_key_on_pipeline_schedule_owner.rb +++ b/db/post_migrate/20170510101043_add_foreign_key_on_pipeline_schedule_owner.rb @@ -29,7 +29,7 @@ class AddForeignKeyOnPipelineScheduleOwner < ActiveRecord::Migration[4.2] if Gitlab::Database.mysql? :nullify else - 'SET NULL' + "SET NULL" end end end diff --git a/db/post_migrate/20170518200835_rename_users_with_renamed_namespace.rb b/db/post_migrate/20170518200835_rename_users_with_renamed_namespace.rb index 4ba78727cc3..411a2598dcc 100644 --- a/db/post_migrate/20170518200835_rename_users_with_renamed_namespace.rb +++ b/db/post_migrate/20170518200835_rename_users_with_renamed_namespace.rb @@ -29,18 +29,18 @@ class RenameUsersWithRenamedNamespace < ActiveRecord::Migration[4.2] users = Arel::Table.new(:users) namespaces = Arel::Table.new(:namespaces) predicate = namespaces[:owner_id].eq(users[:id]) - .and(namespaces[:type].eq(nil)) - .and(users[:username].matches(path)) + .and(namespaces[:type].eq(nil)) + .and(users[:username].matches(path)) update_sql = if Gitlab::Database.postgresql? - "UPDATE users SET username = namespaces.path "\ - "FROM namespaces WHERE #{predicate.to_sql}" - else - "UPDATE users INNER JOIN namespaces "\ - "ON namespaces.owner_id = users.id "\ - "SET username = namespaces.path "\ - "WHERE #{predicate.to_sql}" - end + "UPDATE users SET username = namespaces.path "\ + "FROM namespaces WHERE #{predicate.to_sql}" + else + "UPDATE users INNER JOIN namespaces "\ + "ON namespaces.owner_id = users.id "\ + "SET username = namespaces.path "\ + "WHERE #{predicate.to_sql}" + end connection.execute(update_sql) end diff --git a/db/post_migrate/20170518231126_fix_wrongly_renamed_routes.rb b/db/post_migrate/20170518231126_fix_wrongly_renamed_routes.rb index 28a2a2e01bf..fe657ed4463 100644 --- a/db/post_migrate/20170518231126_fix_wrongly_renamed_routes.rb +++ b/db/post_migrate/20170518231126_fix_wrongly_renamed_routes.rb @@ -32,7 +32,7 @@ class FixWronglyRenamedRoutes < ActiveRecord::Migration[4.2] FIXED_PATHS = DISALLOWED_ROOT_PATHS.map { |p| "#{p}0" } class Route < Gitlab::Database::RenameReservedPathsMigration::V1::MigrationClasses::Route - self.table_name = 'routes' + self.table_name = "routes" end def routes @@ -61,7 +61,7 @@ class FixWronglyRenamedRoutes < ActiveRecord::Migration[4.2] def wrongly_renamed Route.joins("INNER JOIN namespaces ON routes.source_id = namespaces.id") .where( - routes[:source_type].eq('Namespace') + routes[:source_type].eq("Namespace") .and(namespaces[:parent_id].eq(nil)) ) .where(namespaces[:path].matches_any(wildcard_collection(DISALLOWED_ROOT_PATHS))) @@ -77,7 +77,7 @@ class FixWronglyRenamedRoutes < ActiveRecord::Migration[4.2] # def paths_and_corrections connection.select_all( - wrongly_renamed.select(routes[:path], namespaces[:path].as('namespace_path')).to_sql + wrongly_renamed.select(routes[:path], namespaces[:path].as("namespace_path")).to_sql ) end @@ -90,8 +90,8 @@ class FixWronglyRenamedRoutes < ActiveRecord::Migration[4.2] def up paths_and_corrections.each do |root_namespace| - wrong_path = root_namespace['path'] - correct_path = root_namespace['namespace_path'] + wrong_path = root_namespace["path"] + correct_path = root_namespace["namespace_path"] replace_statement = replace_sql(Route.arel_table[:path], wrong_path, correct_path) update_column_in_batches(:routes, :path, replace_statement) do |table, query| diff --git a/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb b/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb index d75bbb2f612..8c0bf16b43c 100644 --- a/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb +++ b/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb @@ -26,7 +26,7 @@ class RemoveAssigneeIdFromIssue < ActiveRecord::Migration[4.2] disable_ddl_transaction! class Issue < ActiveRecord::Base - self.table_name = 'issues' + self.table_name = "issues" include ::EachBatch end @@ -39,7 +39,7 @@ class RemoveAssigneeIdFromIssue < ActiveRecord::Migration[4.2] add_column :issues, :assignee_id, :integer add_concurrent_index :issues, :assignee_id - update_value = Arel.sql('(SELECT user_id FROM issue_assignees WHERE issue_assignees.issue_id = issues.id LIMIT 1)') + update_value = Arel.sql("(SELECT user_id FROM issue_assignees WHERE issue_assignees.issue_id = issues.id LIMIT 1)") # This is only used in the down step, so we can ignore the RuboCop warning # about large tables, as this is very unlikely to be run on GitLab.com diff --git a/db/post_migrate/20170523083112_migrate_old_artifacts.rb b/db/post_migrate/20170523083112_migrate_old_artifacts.rb index 55e155c7619..79feda2a82e 100644 --- a/db/post_migrate/20170523083112_migrate_old_artifacts.rb +++ b/db/post_migrate/20170523083112_migrate_old_artifacts.rb @@ -21,23 +21,23 @@ class MigrateOldArtifacts < ActiveRecord::Migration[4.2] def builds_with_artifacts Build.with_artifacts - .joins('JOIN projects ON projects.id = ci_builds.project_id') - .where('ci_builds.id < ?', min_id) - .where('projects.ci_id IS NOT NULL') - .select('id', 'created_at', 'project_id', 'projects.ci_id AS ci_id') + .joins("JOIN projects ON projects.id = ci_builds.project_id") + .where("ci_builds.id < ?", min_id) + .where("projects.ci_id IS NOT NULL") + .select("id", "created_at", "project_id", "projects.ci_id AS ci_id") end def min_id - Build.joins('JOIN projects ON projects.id = ci_builds.project_id') - .where('projects.ci_id IS NULL') - .pluck('coalesce(min(ci_builds.id), 0)') + Build.joins("JOIN projects ON projects.id = ci_builds.project_id") + .where("projects.ci_id IS NULL") + .pluck("coalesce(min(ci_builds.id), 0)") .first end class Build < ActiveRecord::Base - self.table_name = 'ci_builds' + self.table_name = "ci_builds" - scope :with_artifacts, -> { where.not(artifacts_file: [nil, '']) } + scope :with_artifacts, -> { where.not(artifacts_file: [nil, ""]) } def migrate_artifacts! return unless File.exist?(source_artifacts_path) @@ -53,14 +53,14 @@ class MigrateOldArtifacts < ActiveRecord::Migration[4.2] def source_artifacts_path @source_artifacts_path ||= File.join(Gitlab.config.artifacts.path, - created_at.utc.strftime('%Y_%m'), + created_at.utc.strftime("%Y_%m"), ci_id.to_s, id.to_s) end def target_artifacts_path @target_artifacts_path ||= File.join(Gitlab.config.artifacts.path, - created_at.utc.strftime('%Y_%m'), + created_at.utc.strftime("%Y_%m"), project_id.to_s, id.to_s) end diff --git a/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb b/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb index 59b8daaffdf..bbb0dea9376 100644 --- a/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb +++ b/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb @@ -9,81 +9,81 @@ class RenameAllReservedPathsAgain < ActiveRecord::Migration[4.2] disable_ddl_transaction! TOP_LEVEL_ROUTES = %w[ - - - .well-known - abuse_reports - admin - api - assets - autocomplete - ci - dashboard - explore - files - groups - health_check - help - import - invites - jwt - koding - notification_settings - oauth - profile - projects - public - robots.txt - s - search - sent_notifications - snippets - u - unicorn_test - unsubscribes - uploads - users + - + .well-known + abuse_reports + admin + api + assets + autocomplete + ci + dashboard + explore + files + groups + health_check + help + import + invites + jwt + koding + notification_settings + oauth + profile + projects + public + robots.txt + s + search + sent_notifications + snippets + u + unicorn_test + unsubscribes + uploads + users ].freeze PROJECT_WILDCARD_ROUTES = %w[ - badges - blame - blob - builds - commits - create - create_dir - edit - environments/folders - files - find_file - gitlab-lfs/objects - info/lfs/objects - new - preview - raw - refs - tree - update - wikis - ].freeze + badges + blame + blob + builds + commits + create + create_dir + edit + environments/folders + files + find_file + gitlab-lfs/objects + info/lfs/objects + new + preview + raw + refs + tree + update + wikis + ].freeze GROUP_ROUTES = %w[ - activity - analytics - audit_events - avatar - edit - group_members - hooks - issues - labels - ldap - ldap_group_links - merge_requests - milestones - notification_setting - pipeline_quota - projects + activity + analytics + audit_events + avatar + edit + group_members + hooks + issues + labels + ldap + ldap_group_links + merge_requests + milestones + notification_setting + pipeline_quota + projects ].freeze def up diff --git a/db/post_migrate/20170606202615_move_appearance_to_system_dir.rb b/db/post_migrate/20170606202615_move_appearance_to_system_dir.rb index fb9ac8d6daf..e6f72767dfe 100644 --- a/db/post_migrate/20170606202615_move_appearance_to_system_dir.rb +++ b/db/post_migrate/20170606202615_move_appearance_to_system_dir.rb @@ -3,7 +3,7 @@ class MoveAppearanceToSystemDir < ActiveRecord::Migration[4.2] disable_ddl_transaction! DOWNTIME = false - DIRECTORY_TO_MOVE = 'appearance'.freeze + DIRECTORY_TO_MOVE = "appearance".freeze def up source = File.join(old_upload_dir, DIRECTORY_TO_MOVE) @@ -21,7 +21,7 @@ class MoveAppearanceToSystemDir < ActiveRecord::Migration[4.2] def move_directory(source, destination) unless file_storage? - say 'Not using file storage, skipping' + say "Not using file storage, skipping" return end diff --git a/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb b/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb index 8ff26130cba..8c37891559d 100644 --- a/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb +++ b/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb @@ -6,7 +6,7 @@ class ConvertCustomNotificationSettingsToColumns < ActiveRecord::Migration[4.2] disable_ddl_transaction! class NotificationSetting < ActiveRecord::Base - self.table_name = 'notification_settings' + self.table_name = "notification_settings" store :events, coder: JSON end @@ -23,7 +23,7 @@ class ConvertCustomNotificationSettingsToColumns < ActiveRecord::Migration[4.2] :reassign_merge_request, :merge_merge_request, :failed_pipeline, - :success_pipeline + :success_pipeline, ] # We only need to migrate (up or down) rows where at least one of these @@ -40,7 +40,7 @@ class ConvertCustomNotificationSettingsToColumns < ActiveRecord::Migration[4.2] end def down - NotificationSetting.where(EMAIL_EVENTS.join(' OR ')).find_each do |notification_setting| + NotificationSetting.where(EMAIL_EVENTS.join(" OR ")).find_each do |notification_setting| events = {} EMAIL_EVENTS.each do |event| diff --git a/db/post_migrate/20170612071012_move_personal_snippets_files.rb b/db/post_migrate/20170612071012_move_personal_snippets_files.rb index d32d92637fa..f0063f0bd01 100644 --- a/db/post_migrate/20170612071012_move_personal_snippets_files.rb +++ b/db/post_migrate/20170612071012_move_personal_snippets_files.rb @@ -9,8 +9,8 @@ class MovePersonalSnippetsFiles < ActiveRecord::Migration[4.2] def up return unless file_storage? - @source_relative_location = File.join('/uploads', 'personal_snippet') - @destination_relative_location = File.join('/uploads', '-', 'system', 'personal_snippet') + @source_relative_location = File.join("/uploads", "personal_snippet") + @destination_relative_location = File.join("/uploads", "-", "system", "personal_snippet") move_personal_snippet_files end @@ -18,8 +18,8 @@ class MovePersonalSnippetsFiles < ActiveRecord::Migration[4.2] def down return unless file_storage? - @source_relative_location = File.join('/uploads', '-', 'system', 'personal_snippet') - @destination_relative_location = File.join('/uploads', 'personal_snippet') + @source_relative_location = File.join("/uploads", "-", "system", "personal_snippet") + @destination_relative_location = File.join("/uploads", "personal_snippet") move_personal_snippet_files end @@ -28,12 +28,12 @@ class MovePersonalSnippetsFiles < ActiveRecord::Migration[4.2] query = "SELECT uploads.path, uploads.model_id, snippets.description FROM uploads "\ "INNER JOIN snippets ON snippets.id = uploads.model_id WHERE uploader = 'PersonalFileUploader'" select_all(query).each do |upload| - secret = upload['path'].split('/')[0] - file_name = upload['path'].split('/')[1] + secret = upload["path"].split("/")[0] + file_name = upload["path"].split("/")[1] - next unless move_file(upload['model_id'], secret, file_name) + next unless move_file(upload["model_id"], secret, file_name) - update_markdown(upload['model_id'], secret, file_name, upload['description']) + update_markdown(upload["model_id"], secret, file_name, upload["description"]) end end @@ -75,15 +75,15 @@ class MovePersonalSnippetsFiles < ActiveRecord::Migration[4.2] query = "SELECT id, note FROM notes WHERE noteable_id = #{snippet_id} "\ "AND noteable_type = 'Snippet' AND note IS NOT NULL" select_all(query).each do |note| - text = note['note'].gsub(source_markdown, destination_markdown) + text = note["note"].gsub(source_markdown, destination_markdown) quoted_text = quote_string(text) - execute("UPDATE notes SET note = '#{quoted_text}', note_html = NULL WHERE id = #{note['id']}") + execute("UPDATE notes SET note = '#{quoted_text}', note_html = NULL WHERE id = #{note["id"]}") end end def base_directory - File.join(Rails.root, 'public') + File.join(Rails.root, "public") end def file_storage? diff --git a/db/post_migrate/20170613111224_clean_appearance_symlinks.rb b/db/post_migrate/20170613111224_clean_appearance_symlinks.rb index 14511bff3db..0be51d1c1f6 100644 --- a/db/post_migrate/20170613111224_clean_appearance_symlinks.rb +++ b/db/post_migrate/20170613111224_clean_appearance_symlinks.rb @@ -36,7 +36,7 @@ class CleanAppearanceSymlinks < ActiveRecord::Migration[4.2] end def dir - 'appearance' + "appearance" end def base_directory diff --git a/db/post_migrate/20170627101016_schedule_event_migrations.rb b/db/post_migrate/20170627101016_schedule_event_migrations.rb index f026a86bc0f..c87e8d0c8f2 100644 --- a/db/post_migrate/20170627101016_schedule_event_migrations.rb +++ b/db/post_migrate/20170627101016_schedule_event_migrations.rb @@ -12,14 +12,14 @@ class ScheduleEventMigrations < ActiveRecord::Migration[4.2] class Event < ActiveRecord::Base include EachBatch - self.table_name = 'events' + self.table_name = "events" end def up jobs = [] Event.each_batch(of: 1000) do |relation| - min, max = relation.pluck('MIN(id), MAX(id)').first + min, max = relation.pluck("MIN(id), MAX(id)").first if jobs.length == BUFFER_SIZE # We push multiple jobs at a time to reduce the time spent in @@ -29,7 +29,7 @@ class ScheduleEventMigrations < ActiveRecord::Migration[4.2] jobs.clear end - jobs << ['MigrateEventsToPushEventPayloads', [min, max]] + jobs << ["MigrateEventsToPushEventPayloads", [min, max]] end BackgroundMigrationWorker.bulk_perform_async(jobs) unless jobs.empty? diff --git a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb b/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb index 36aac3df071..81222ef0f8f 100644 --- a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb +++ b/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb @@ -4,12 +4,12 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration[4.2] DOWNTIME = false BATCH_SIZE = 10000 RANGE_SIZE = 1000 - MIGRATION = 'MigrateBuildStageIdReference'.freeze + MIGRATION = "MigrateBuildStageIdReference".freeze disable_ddl_transaction! class Build < ActiveRecord::Base - self.table_name = 'ci_builds' + self.table_name = "ci_builds" include ::EachBatch end @@ -19,7 +19,7 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration[4.2] def up Build.where(stage_id: nil).each_batch(of: BATCH_SIZE) do |relation, index| relation.each_batch(of: RANGE_SIZE) do |relation| - range = relation.pluck('MIN(id)', 'MAX(id)').first + range = relation.pluck("MIN(id)", "MAX(id)").first BackgroundMigrationWorker .perform_in(index * 2.minutes, MIGRATION, range) diff --git a/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb b/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb index fd4b2859f7f..aee88e7a466 100644 --- a/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb +++ b/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb @@ -3,12 +3,12 @@ class ScheduleMergeRequestDiffMigrations < ActiveRecord::Migration[4.2] DOWNTIME = false BATCH_SIZE = 2500 - MIGRATION = 'DeserializeMergeRequestDiffsAndCommits' + MIGRATION = "DeserializeMergeRequestDiffsAndCommits" disable_ddl_transaction! class MergeRequestDiff < ActiveRecord::Base - self.table_name = 'merge_request_diffs' + self.table_name = "merge_request_diffs" include ::EachBatch end @@ -19,10 +19,10 @@ class ScheduleMergeRequestDiffMigrations < ActiveRecord::Migration[4.2] # # On staging, plucking the IDs themselves takes 5 seconds. def up - non_empty = 'st_commits IS NOT NULL OR st_diffs IS NOT NULL' + non_empty = "st_commits IS NOT NULL OR st_diffs IS NOT NULL" MergeRequestDiff.where(non_empty).each_batch(of: BATCH_SIZE) do |relation, index| - range = relation.pluck('MIN(id)', 'MAX(id)').first + range = relation.pluck("MIN(id)", "MAX(id)").first BackgroundMigrationWorker.perform_in(index * 5.minutes, MIGRATION, range) end diff --git a/db/post_migrate/20170711145558_migrate_stages_statuses.rb b/db/post_migrate/20170711145558_migrate_stages_statuses.rb index 8ba69ea4dce..56d99111032 100644 --- a/db/post_migrate/20170711145558_migrate_stages_statuses.rb +++ b/db/post_migrate/20170711145558_migrate_stages_statuses.rb @@ -7,17 +7,17 @@ class MigrateStagesStatuses < ActiveRecord::Migration[4.2] BATCH_SIZE = 10000 RANGE_SIZE = 100 - MIGRATION = 'MigrateStageStatus'.freeze + MIGRATION = "MigrateStageStatus".freeze class Stage < ActiveRecord::Base - self.table_name = 'ci_stages' + self.table_name = "ci_stages" include ::EachBatch end def up Stage.where(status: nil).each_batch(of: BATCH_SIZE) do |relation, index| relation.each_batch(of: RANGE_SIZE) do |batch| - range = batch.pluck('MIN(id)', 'MAX(id)').first + range = batch.pluck("MIN(id)", "MAX(id)").first delay = index * 5.minutes BackgroundMigrationWorker.perform_in(delay, MIGRATION, range) diff --git a/db/post_migrate/20170717111152_cleanup_move_system_upload_folder_symlink.rb b/db/post_migrate/20170717111152_cleanup_move_system_upload_folder_symlink.rb index 392c4f71532..7a74f43e9a6 100644 --- a/db/post_migrate/20170717111152_cleanup_move_system_upload_folder_symlink.rb +++ b/db/post_migrate/20170717111152_cleanup_move_system_upload_folder_symlink.rb @@ -27,14 +27,14 @@ class CleanupMoveSystemUploadFolderSymlink < ActiveRecord::Migration[4.2] end def new_directory - File.join(base_directory, '-', 'system') + File.join(base_directory, "-", "system") end def old_directory - File.join(base_directory, 'system') + File.join(base_directory, "system") end def base_directory - File.join(Rails.root, 'public', 'uploads') + File.join(Rails.root, "public", "uploads") end end diff --git a/db/post_migrate/20170717150329_enqueue_migrate_system_uploads_to_new_folder.rb b/db/post_migrate/20170717150329_enqueue_migrate_system_uploads_to_new_folder.rb index fdd990ae2e5..fc70be48b96 100644 --- a/db/post_migrate/20170717150329_enqueue_migrate_system_uploads_to_new_folder.rb +++ b/db/post_migrate/20170717150329_enqueue_migrate_system_uploads_to_new_folder.rb @@ -3,18 +3,18 @@ class EnqueueMigrateSystemUploadsToNewFolder < ActiveRecord::Migration[4.2] DOWNTIME = false - OLD_FOLDER = 'uploads/system/' - NEW_FOLDER = 'uploads/-/system/' + OLD_FOLDER = "uploads/system/" + NEW_FOLDER = "uploads/-/system/" disable_ddl_transaction! def up - BackgroundMigrationWorker.perform_async('MigrateSystemUploadsToNewFolder', - [OLD_FOLDER, NEW_FOLDER]) + BackgroundMigrationWorker.perform_async("MigrateSystemUploadsToNewFolder", + [OLD_FOLDER, NEW_FOLDER]) end def down - BackgroundMigrationWorker.perform_async('MigrateSystemUploadsToNewFolder', - [NEW_FOLDER, OLD_FOLDER]) + BackgroundMigrationWorker.perform_async("MigrateSystemUploadsToNewFolder", + [NEW_FOLDER, OLD_FOLDER]) end end diff --git a/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb b/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb index 7af1d04f0cc..94486bdd194 100644 --- a/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb +++ b/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb @@ -9,13 +9,13 @@ class MergeIssuableReopenedIntoOpenedState < ActiveRecord::Migration[4.2] disable_ddl_transaction! class Issue < ActiveRecord::Base - self.table_name = 'issues' + self.table_name = "issues" include EachBatch end class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' + self.table_name = "merge_requests" include EachBatch end @@ -24,8 +24,8 @@ class MergeIssuableReopenedIntoOpenedState < ActiveRecord::Migration[4.2] [Issue, MergeRequest].each do |model| say "Changing #{model.table_name}.state from 'reopened' to 'opened'" - model.where(state: 'reopened').each_batch do |batch| - batch.update_all(state: 'opened') + model.where(state: "reopened").each_batch do |batch| + batch.update_all(state: "opened") end end end diff --git a/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb b/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb index a148586ca89..900bc558a84 100644 --- a/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb +++ b/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb @@ -3,7 +3,7 @@ class CalculateConvDevIndexPercentages < ActiveRecord::Migration[4.2] DOWNTIME = false class ConversationalDevelopmentIndexMetric < ActiveRecord::Base - self.table_name = 'conversational_development_index_metrics' + self.table_name = "conversational_development_index_metrics" METRICS = %w[boards ci_pipelines deployments environments issues merge_requests milestones notes projects_prometheus_active service_desk_issues] @@ -21,7 +21,7 @@ class CalculateConvDevIndexPercentages < ActiveRecord::Migration[4.2] update << "percentage_#{metric} = '#{percentage}'" end - execute("UPDATE conversational_development_index_metrics SET #{update.join(',')} WHERE id = #{conv_dev_index.id}") + execute("UPDATE conversational_development_index_metrics SET #{update.join(",")} WHERE id = #{conv_dev_index.id}") end end diff --git a/db/post_migrate/20170807190736_move_personal_snippet_files_into_correct_folder.rb b/db/post_migrate/20170807190736_move_personal_snippet_files_into_correct_folder.rb index 8341ac39c25..7938316a62d 100644 --- a/db/post_migrate/20170807190736_move_personal_snippet_files_into_correct_folder.rb +++ b/db/post_migrate/20170807190736_move_personal_snippet_files_into_correct_folder.rb @@ -6,21 +6,21 @@ class MovePersonalSnippetFilesIntoCorrectFolder < ActiveRecord::Migration[4.2] disable_ddl_transaction! DOWNTIME = false - NEW_DIRECTORY = File.join('/uploads', '-', 'system', 'personal_snippet') - OLD_DIRECTORY = File.join('/uploads', 'system', 'personal_snippet') + NEW_DIRECTORY = File.join("/uploads", "-", "system", "personal_snippet") + OLD_DIRECTORY = File.join("/uploads", "system", "personal_snippet") def up return unless file_storage? - BackgroundMigrationWorker.perform_async('MovePersonalSnippetFiles', - [OLD_DIRECTORY, NEW_DIRECTORY]) + BackgroundMigrationWorker.perform_async("MovePersonalSnippetFiles", + [OLD_DIRECTORY, NEW_DIRECTORY]) end def down return unless file_storage? - BackgroundMigrationWorker.perform_async('MovePersonalSnippetFiles', - [NEW_DIRECTORY, OLD_DIRECTORY]) + BackgroundMigrationWorker.perform_async("MovePersonalSnippetFiles", + [NEW_DIRECTORY, OLD_DIRECTORY]) end def file_storage? diff --git a/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb b/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb index fdc126b8fd6..c82b1f4043e 100644 --- a/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb +++ b/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb @@ -6,14 +6,14 @@ class RemoveDuplicateMrEvents < ActiveRecord::Migration[4.2] DOWNTIME = false class Event < ActiveRecord::Base - self.table_name = 'events' + self.table_name = "events" end def up base_condition = "action = 1 AND target_type = 'MergeRequest' AND created_at > '2017-08-13'" - Event.select('target_id, count(*)') + Event.select("target_id, count(*)") .where(base_condition) - .group('target_id').having('count(*) > 1').each do |event| + .group("target_id").having("count(*) > 1").each do |event| duplicates = Event.where("#{base_condition} AND target_id = #{event.target_id}").pluck(:id) duplicates.shift diff --git a/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb b/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb index 27656fd926d..d0cb1893f5c 100644 --- a/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb +++ b/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb @@ -9,13 +9,13 @@ class CleanupNonexistingNamespacePendingDeleteProjects < ActiveRecord::Migration disable_ddl_transaction! class Project < ActiveRecord::Base - self.table_name = 'projects' + self.table_name = "projects" include ::EachBatch end class Namespace < ActiveRecord::Base - self.table_name = 'namespaces' + self.table_name = "namespaces" end def up @@ -37,8 +37,8 @@ class CleanupNonexistingNamespacePendingDeleteProjects < ActiveRecord::Migration namespaces = Namespace.arel_table namespace_query = namespaces.project(1) - .where(namespaces[:id].eq(projects[:namespace_id])) - .exists.not + .where(namespaces[:id].eq(projects[:namespace_id])) + .exists.not # SELECT "projects"."id" # FROM "projects" diff --git a/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb b/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb index 825bc9250bd..ae2cd6d9718 100644 --- a/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb +++ b/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb @@ -4,14 +4,14 @@ class MigratePipelineSidekiqQueues < ActiveRecord::Migration[4.2] DOWNTIME = false def up - sidekiq_queue_migrate 'build', to: 'pipeline_default' - sidekiq_queue_migrate 'pipeline', to: 'pipeline_default' + sidekiq_queue_migrate "build", to: "pipeline_default" + sidekiq_queue_migrate "pipeline", to: "pipeline_default" end def down - sidekiq_queue_migrate 'pipeline_default', to: 'pipeline' - sidekiq_queue_migrate 'pipeline_processing', to: 'pipeline' - sidekiq_queue_migrate 'pipeline_hooks', to: 'pipeline' - sidekiq_queue_migrate 'pipeline_cache', to: 'pipeline' + sidekiq_queue_migrate "pipeline_default", to: "pipeline" + sidekiq_queue_migrate "pipeline_processing", to: "pipeline" + sidekiq_queue_migrate "pipeline_hooks", to: "pipeline" + sidekiq_queue_migrate "pipeline_cache", to: "pipeline" end end diff --git a/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb b/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb index 533155aeb7a..4f9fcd01384 100644 --- a/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb +++ b/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb @@ -9,20 +9,20 @@ class PostDeployMigrateUserExternalMailData < ActiveRecord::Migration[4.2] disable_ddl_transaction! class User < ActiveRecord::Base - self.table_name = 'users' + self.table_name = "users" include EachBatch end class UserSyncedAttributesMetadata < ActiveRecord::Base - self.table_name = 'user_synced_attributes_metadata' + self.table_name = "user_synced_attributes_metadata" include EachBatch end def up User.each_batch do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first + start_id, end_id = batch.pluck("MIN(id), MAX(id)").first execute <<-EOF INSERT INTO user_synced_attributes_metadata (user_id, provider, email_synced) @@ -42,7 +42,7 @@ class PostDeployMigrateUserExternalMailData < ActiveRecord::Migration[4.2] def down UserSyncedAttributesMetadata.each_batch do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first + start_id, end_id = batch.pluck("MIN(id), MAX(id)").first execute <<-EOF UPDATE users diff --git a/db/post_migrate/20170830150306_drop_events_for_migration_table.rb b/db/post_migrate/20170830150306_drop_events_for_migration_table.rb index 3538b52b004..d8f26f2d55c 100644 --- a/db/post_migrate/20170830150306_drop_events_for_migration_table.rb +++ b/db/post_migrate/20170830150306_drop_events_for_migration_table.rb @@ -34,7 +34,7 @@ class DropEventsForMigrationTable < ActiveRecord::Migration[4.2] end Event.all.each_batch do |relation| - start_id, stop_id = relation.pluck('MIN(id), MAX(id)').first + start_id, stop_id = relation.pluck("MIN(id), MAX(id)").first execute <<-EOF.strip_heredoc INSERT INTO events_for_migration (target_type, target_id, project_id, created_at, updated_at, action, author_id) diff --git a/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb b/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb index bbc624ac7c0..060244b5859 100644 --- a/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb +++ b/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb @@ -8,7 +8,7 @@ class FixProjectsWithoutProjectFeature < ActiveRecord::Migration[4.2] # Creates missing project features with private visibility sql = - %Q{ + %{ INSERT INTO project_features(project_id, repository_access_level, issues_access_level, merge_requests_access_level, wiki_access_level, builds_access_level, snippets_access_level, created_at, updated_at) SELECT projects.id as project_id, diff --git a/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb b/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb index 9080acee1d6..26d7fee93b8 100644 --- a/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb +++ b/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb @@ -5,7 +5,7 @@ class NormalizeLdapExternUids < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - MIGRATION = 'NormalizeLdapExternUidsRange'.freeze + MIGRATION = "NormalizeLdapExternUidsRange".freeze DELAY_INTERVAL = 10.seconds disable_ddl_transaction! @@ -13,7 +13,7 @@ class NormalizeLdapExternUids < ActiveRecord::Migration[4.2] class Identity < ActiveRecord::Base include EachBatch - self.table_name = 'identities' + self.table_name = "identities" end def up diff --git a/db/post_migrate/20170926150348_schedule_merge_request_diff_migrations_take_two.rb b/db/post_migrate/20170926150348_schedule_merge_request_diff_migrations_take_two.rb index 9b675a51725..cc8468c9bbb 100644 --- a/db/post_migrate/20170926150348_schedule_merge_request_diff_migrations_take_two.rb +++ b/db/post_migrate/20170926150348_schedule_merge_request_diff_migrations_take_two.rb @@ -3,17 +3,17 @@ class ScheduleMergeRequestDiffMigrationsTakeTwo < ActiveRecord::Migration[4.2] DOWNTIME = false BATCH_SIZE = 500 - MIGRATION = 'DeserializeMergeRequestDiffsAndCommits' + MIGRATION = "DeserializeMergeRequestDiffsAndCommits" DELAY_INTERVAL = 10.minutes disable_ddl_transaction! class MergeRequestDiff < ActiveRecord::Base - self.table_name = 'merge_request_diffs' + self.table_name = "merge_request_diffs" include ::EachBatch - default_scope { where('st_commits IS NOT NULL OR st_diffs IS NOT NULL') } + default_scope { where("st_commits IS NOT NULL OR st_diffs IS NOT NULL") } end # By this point, we assume ScheduleMergeRequestDiffMigrations - the first diff --git a/db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb b/db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb index 83c21c203e0..3df2551bd77 100644 --- a/db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb +++ b/db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb @@ -7,8 +7,8 @@ class UpdateLegacyDiffNotesTypeForImport < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - update_column_in_batches(:notes, :type, 'LegacyDiffNote') do |table, query| - query.where(table[:type].eq('Github::Import::LegacyDiffNote')) + update_column_in_batches(:notes, :type, "LegacyDiffNote") do |table, query| + query.where(table[:type].eq("Github::Import::LegacyDiffNote")) end end diff --git a/db/post_migrate/20170927112319_update_notes_type_for_import.rb b/db/post_migrate/20170927112319_update_notes_type_for_import.rb index 8c691de3192..efd022a2143 100644 --- a/db/post_migrate/20170927112319_update_notes_type_for_import.rb +++ b/db/post_migrate/20170927112319_update_notes_type_for_import.rb @@ -7,8 +7,8 @@ class UpdateNotesTypeForImport < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - update_column_in_batches(:notes, :type, 'Note') do |table, query| - query.where(table[:type].eq('Github::Import::Note')) + update_column_in_batches(:notes, :type, "Note") do |table, query| + query.where(table[:type].eq("Github::Import::Note")) end end diff --git a/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb b/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb index e49a70f902c..a490f1c5c39 100644 --- a/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb +++ b/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb @@ -5,19 +5,19 @@ class ScheduleCreateGpgKeySubkeysFromGpgKeys < ActiveRecord::Migration[4.2] disable_ddl_transaction! DOWNTIME = false - MIGRATION = 'CreateGpgKeySubkeysFromGpgKeys' + MIGRATION = "CreateGpgKeySubkeysFromGpgKeys" class GpgKey < ActiveRecord::Base - self.table_name = 'gpg_keys' + self.table_name = "gpg_keys" include EachBatch end def up GpgKey.select(:id).each_batch do |gpg_keys| - jobs = gpg_keys.pluck(:id).map do |id| + jobs = gpg_keys.pluck(:id).map { |id| [MIGRATION, [id]] - end + } BackgroundMigrationWorker.bulk_perform_async(jobs) end diff --git a/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb b/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb index 9c90aa611a4..ae9d342ea5f 100644 --- a/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb +++ b/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb @@ -2,54 +2,54 @@ class MigrateGcpClustersToNewClustersArchitectures < ActiveRecord::Migration[4.2 DOWNTIME = false class GcpCluster < ActiveRecord::Base - self.table_name = 'gcp_clusters' + self.table_name = "gcp_clusters" - belongs_to :project, class_name: 'Project' + belongs_to :project, class_name: "Project" include EachBatch end class Cluster < ActiveRecord::Base - self.table_name = 'clusters' + self.table_name = "clusters" - has_many :cluster_projects, class_name: 'ClustersProject' - has_many :projects, through: :cluster_projects, class_name: 'Project' - has_one :provider_gcp, class_name: 'ProvidersGcp' - has_one :platform_kubernetes, class_name: 'PlatformsKubernetes' + has_many :cluster_projects, class_name: "ClustersProject" + has_many :projects, through: :cluster_projects, class_name: "Project" + has_one :provider_gcp, class_name: "ProvidersGcp" + has_one :platform_kubernetes, class_name: "PlatformsKubernetes" accepts_nested_attributes_for :provider_gcp accepts_nested_attributes_for :platform_kubernetes enum platform_type: { - kubernetes: 1 + kubernetes: 1, } enum provider_type: { user: 0, - gcp: 1 + gcp: 1, } end class Project < ActiveRecord::Base - self.table_name = 'projects' + self.table_name = "projects" - has_one :cluster_project, class_name: 'ClustersProject' - has_one :cluster, through: :cluster_project, class_name: 'Cluster' + has_one :cluster_project, class_name: "ClustersProject" + has_one :cluster, through: :cluster_project, class_name: "Cluster" end class ClustersProject < ActiveRecord::Base - self.table_name = 'cluster_projects' + self.table_name = "cluster_projects" - belongs_to :cluster, class_name: 'Cluster' - belongs_to :project, class_name: 'Project' + belongs_to :cluster, class_name: "Cluster" + belongs_to :project, class_name: "Project" end class ProvidersGcp < ActiveRecord::Base - self.table_name = 'cluster_providers_gcp' + self.table_name = "cluster_providers_gcp" end class PlatformsKubernetes < ActiveRecord::Base - self.table_name = 'cluster_platforms_kubernetes' + self.table_name = "cluster_platforms_kubernetes" end def up @@ -71,7 +71,7 @@ class MigrateGcpClustersToNewClustersArchitectures < ActiveRecord::Migration[4.2 operation_id: gcp_cluster.gcp_operation_id, endpoint: gcp_cluster.endpoint, encrypted_access_token: gcp_cluster.encrypted_gcp_token, - encrypted_access_token_iv: gcp_cluster.encrypted_gcp_token_iv + encrypted_access_token_iv: gcp_cluster.encrypted_gcp_token_iv, }, platform_kubernetes_attributes: { api_url: api_url(gcp_cluster.endpoint), @@ -81,18 +81,19 @@ class MigrateGcpClustersToNewClustersArchitectures < ActiveRecord::Migration[4.2 encrypted_password: gcp_cluster.encrypted_password, encrypted_password_iv: gcp_cluster.encrypted_password_iv, encrypted_token: gcp_cluster.encrypted_kubernetes_token, - encrypted_token_iv: gcp_cluster.encrypted_kubernetes_token_iv - } ) + encrypted_token_iv: gcp_cluster.encrypted_kubernetes_token_iv, + } + ) end end def down - execute('DELETE FROM clusters') + execute("DELETE FROM clusters") end private def api_url(endpoint) - endpoint ? 'https://' + endpoint : nil + endpoint ? "https://" + endpoint : nil end end diff --git a/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb b/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb index 764561de997..74b26c54d97 100644 --- a/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb +++ b/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb @@ -3,12 +3,12 @@ class ScheduleMergeRequestLatestMergeRequestDiffIdMigrations < ActiveRecord::Mig DOWNTIME = false BATCH_SIZE = 50_000 - MIGRATION = 'PopulateMergeRequestsLatestMergeRequestDiffId' + MIGRATION = "PopulateMergeRequestsLatestMergeRequestDiffId" disable_ddl_transaction! class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' + self.table_name = "merge_requests" include ::EachBatch end @@ -21,7 +21,7 @@ class ScheduleMergeRequestLatestMergeRequestDiffIdMigrations < ActiveRecord::Mig # we can migrate all the rows in 8.5 hours. def up MergeRequest.where(latest_merge_request_diff_id: nil).each_batch(of: BATCH_SIZE) do |relation, index| - range = relation.pluck('MIN(id)', 'MAX(id)').first + range = relation.pluck("MIN(id)", "MAX(id)").first BackgroundMigrationWorker.perform_in(index * 5.minutes, MIGRATION, range) end diff --git a/db/post_migrate/20171103140253_track_untracked_uploads.rb b/db/post_migrate/20171103140253_track_untracked_uploads.rb index 6891ef5ba12..e291ac8b499 100644 --- a/db/post_migrate/20171103140253_track_untracked_uploads.rb +++ b/db/post_migrate/20171103140253_track_untracked_uploads.rb @@ -7,7 +7,7 @@ class TrackUntrackedUploads < ActiveRecord::Migration[4.2] disable_ddl_transaction! DOWNTIME = false - MIGRATION = 'PrepareUntrackedUploads' + MIGRATION = "PrepareUntrackedUploads" def up BackgroundMigrationWorker.perform_async(MIGRATION) diff --git a/db/post_migrate/20171114104051_remove_empty_fork_networks.rb b/db/post_migrate/20171114104051_remove_empty_fork_networks.rb index 76862cccf60..8ff8a44b4ba 100644 --- a/db/post_migrate/20171114104051_remove_empty_fork_networks.rb +++ b/db/post_migrate/20171114104051_remove_empty_fork_networks.rb @@ -7,22 +7,22 @@ class RemoveEmptyForkNetworks < ActiveRecord::Migration[4.2] class MigrationForkNetwork < ActiveRecord::Base include EachBatch - self.table_name = 'fork_networks' + self.table_name = "fork_networks" end class MigrationForkNetworkMembers < ActiveRecord::Base - self.table_name = 'fork_network_members' + self.table_name = "fork_network_members" end disable_ddl_transaction! def up - say 'Deleting empty ForkNetworks in batches' + say "Deleting empty ForkNetworks in batches" has_members = MigrationForkNetworkMembers - .where('fork_network_members.fork_network_id = fork_networks.id') - .select(1) - MigrationForkNetwork.where('NOT EXISTS (?)', has_members) + .where("fork_network_members.fork_network_id = fork_networks.id") + .select(1) + MigrationForkNetwork.where("NOT EXISTS (?)", has_members) .each_batch(of: BATCH_SIZE) do |networks| deleted = networks.delete_all diff --git a/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb b/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb index ae954289291..eda40a749c3 100644 --- a/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb +++ b/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb @@ -10,11 +10,11 @@ class UpdateCircuitbreakerDefaults < ActiveRecord::Migration[4.2] def up change_column_default :application_settings, - :circuitbreaker_failure_count_threshold, - 3 + :circuitbreaker_failure_count_threshold, + 3 change_column_default :application_settings, - :circuitbreaker_storage_timeout, - 15 + :circuitbreaker_storage_timeout, + 15 ApplicationSetting.update_all(circuitbreaker_failure_count_threshold: 3, circuitbreaker_storage_timeout: 15) @@ -22,11 +22,11 @@ class UpdateCircuitbreakerDefaults < ActiveRecord::Migration[4.2] def down change_column_default :application_settings, - :circuitbreaker_failure_count_threshold, - 160 + :circuitbreaker_failure_count_threshold, + 160 change_column_default :application_settings, - :circuitbreaker_storage_timeout, - 30 + :circuitbreaker_storage_timeout, + 30 ApplicationSetting.update_all(circuitbreaker_failure_count_threshold: 160, circuitbreaker_storage_timeout: 30) diff --git a/db/post_migrate/20171123101046_remove_old_circuitbreaker_config.rb b/db/post_migrate/20171123101046_remove_old_circuitbreaker_config.rb index 3f2c1b2170a..322e8308702 100644 --- a/db/post_migrate/20171123101046_remove_old_circuitbreaker_config.rb +++ b/db/post_migrate/20171123101046_remove_old_circuitbreaker_config.rb @@ -8,19 +8,19 @@ class RemoveOldCircuitbreakerConfig < ActiveRecord::Migration[4.2] def up remove_column :application_settings, - :circuitbreaker_backoff_threshold + :circuitbreaker_backoff_threshold remove_column :application_settings, - :circuitbreaker_failure_wait_time + :circuitbreaker_failure_wait_time end def down add_column :application_settings, - :circuitbreaker_backoff_threshold, - :integer, - default: 80 + :circuitbreaker_backoff_threshold, + :integer, + default: 80 add_column :application_settings, - :circuitbreaker_failure_wait_time, - :integer, - default: 30 + :circuitbreaker_failure_wait_time, + :integer, + default: 30 end end diff --git a/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb b/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb index 58ceefe3c97..6de6d1c02d2 100644 --- a/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb +++ b/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb @@ -2,107 +2,107 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati include Gitlab::Database::MigrationHelpers DOWNTIME = false - DEFAULT_KUBERNETES_SERVICE_CLUSTER_NAME = 'KubernetesService'.freeze + DEFAULT_KUBERNETES_SERVICE_CLUSTER_NAME = "KubernetesService".freeze disable_ddl_transaction! class Project < ActiveRecord::Base - self.table_name = 'projects' + self.table_name = "projects" - has_many :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject' - has_many :clusters, through: :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster' - has_many :services, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Service' - has_one :kubernetes_service, -> { where(category: 'deployment', type: 'KubernetesService') }, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Service', inverse_of: :project, foreign_key: :project_id + has_many :cluster_projects, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject" + has_many :clusters, through: :cluster_projects, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Cluster" + has_many :services, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Service" + has_one :kubernetes_service, -> { where(category: "deployment", type: "KubernetesService") }, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Service", inverse_of: :project, foreign_key: :project_id end class Cluster < ActiveRecord::Base - self.table_name = 'clusters' + self.table_name = "clusters" - has_many :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject' - has_many :projects, through: :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Project' - has_one :platform_kubernetes, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::PlatformsKubernetes' + has_many :cluster_projects, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject" + has_many :projects, through: :cluster_projects, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Project" + has_one :platform_kubernetes, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::PlatformsKubernetes" accepts_nested_attributes_for :platform_kubernetes enum platform_type: { - kubernetes: 1 + kubernetes: 1, } enum provider_type: { user: 0, - gcp: 1 + gcp: 1, } end class ClustersProject < ActiveRecord::Base - self.table_name = 'cluster_projects' + self.table_name = "cluster_projects" - belongs_to :cluster, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster' - belongs_to :project, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Project' + belongs_to :cluster, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Cluster" + belongs_to :project, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Project" end class PlatformsKubernetes < ActiveRecord::Base - self.table_name = 'cluster_platforms_kubernetes' + self.table_name = "cluster_platforms_kubernetes" - belongs_to :cluster, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster' + belongs_to :cluster, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Cluster" attr_encrypted :token, mode: :per_attribute_iv, key: Settings.attr_encrypted_db_key_base_truncated, - algorithm: 'aes-256-cbc' + algorithm: "aes-256-cbc" end class Service < ActiveRecord::Base include EachBatch - self.table_name = 'services' + self.table_name = "services" self.inheritance_column = :_type_disabled # Disable STI, otherwise KubernetesModel will be looked up - belongs_to :project, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Project', foreign_key: :project_id + belongs_to :project, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Project", foreign_key: :project_id scope :unmanaged_kubernetes_service, -> do - joins('LEFT JOIN projects ON projects.id = services.project_id') - .joins('LEFT JOIN cluster_projects ON cluster_projects.project_id = projects.id') - .joins('LEFT JOIN cluster_platforms_kubernetes ON cluster_platforms_kubernetes.cluster_id = cluster_projects.cluster_id') - .where(category: 'deployment', type: 'KubernetesService', template: false) - .where("services.properties LIKE '%api_url%'") - .where("(services.properties NOT LIKE CONCAT('%', cluster_platforms_kubernetes.api_url, '%')) OR cluster_platforms_kubernetes.api_url IS NULL") - .group(:id) - .order(id: :asc) + joins("LEFT JOIN projects ON projects.id = services.project_id") + .joins("LEFT JOIN cluster_projects ON cluster_projects.project_id = projects.id") + .joins("LEFT JOIN cluster_platforms_kubernetes ON cluster_platforms_kubernetes.cluster_id = cluster_projects.cluster_id") + .where(category: "deployment", type: "KubernetesService", template: false) + .where("services.properties LIKE '%api_url%'") + .where("(services.properties NOT LIKE CONCAT('%', cluster_platforms_kubernetes.api_url, '%')) OR cluster_platforms_kubernetes.api_url IS NULL") + .group(:id) + .order(id: :asc) end scope :kubernetes_service_without_template, -> do - where(category: 'deployment', type: 'KubernetesService', template: false) + where(category: "deployment", type: "KubernetesService", template: false) end def api_url - parsed_properties['api_url'] + parsed_properties["api_url"] end def ca_pem - parsed_properties['ca_pem'] + parsed_properties["ca_pem"] end def namespace - parsed_properties['namespace'] + parsed_properties["namespace"] end def token - parsed_properties['token'] + parsed_properties["token"] end private def parsed_properties - @parsed_properties ||= JSON.parse(self.properties) + @parsed_properties ||= JSON.parse(properties) end end def find_dedicated_environement_scope(project) environment_scopes = project.clusters.map(&:environment_scope) - return '*' if environment_scopes.exclude?('*') # KubernetesService should be added as a default cluster (environment_scope: '*') at first place - return 'migrated/*' if environment_scopes.exclude?('migrated/*') # If it's conflicted, the KubernetesService added as a migrated cluster + return "*" if environment_scopes.exclude?("*") # KubernetesService should be added as a default cluster (environment_scope: '*') at first place + return "migrated/*" if environment_scopes.exclude?("migrated/*") # If it's conflicted, the KubernetesService added as a migrated cluster unique_iid = 0 @@ -134,8 +134,9 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati username: nil, # KubernetesService doesn't have encrypted_password: nil, # KubernetesService doesn't have encrypted_password_iv: nil, # KubernetesService doesn't have - token: kubernetes_service.token # encrypted_token and encrypted_token_iv - } ) + token: kubernetes_service.token, # encrypted_token and encrypted_token_iv + } + ) end end diff --git a/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb b/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb index 8e320ea9e8d..0789081c175 100644 --- a/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb +++ b/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb @@ -4,7 +4,7 @@ class RescheduleForkNetworkCreation < ActiveRecord::Migration[4.2] DOWNTIME = false def up - say 'Fork networks will be populated in 20171205190711 - RescheduleForkNetworkCreationCaller' + say "Fork networks will be populated in 20171205190711 - RescheduleForkNetworkCreationCaller" end def down diff --git a/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb b/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb index 51441a36e4b..d11b72652f7 100644 --- a/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb +++ b/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb @@ -3,18 +3,18 @@ class SchedulePopulateMergeRequestMetricsWithEventsData < ActiveRecord::Migration[4.2] DOWNTIME = false BATCH_SIZE = 10_000 - MIGRATION = 'PopulateMergeRequestMetricsWithEventsData' + MIGRATION = "PopulateMergeRequestMetricsWithEventsData" disable_ddl_transaction! class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' + self.table_name = "merge_requests" include ::EachBatch end def up - say 'Scheduling `PopulateMergeRequestMetricsWithEventsData` jobs' + say "Scheduling `PopulateMergeRequestMetricsWithEventsData` jobs" # It will update around 4_000_000 records in batches of 10_000 merge # requests (running between 10 minutes) and should take around 66 hours to complete. # Apparently, production PostgreSQL is able to vacuum 10k-20k dead_tuples by @@ -23,7 +23,7 @@ class SchedulePopulateMergeRequestMetricsWithEventsData < ActiveRecord::Migratio # More information about the updates in `PopulateMergeRequestMetricsWithEventsData` class. # MergeRequest.all.each_batch(of: BATCH_SIZE) do |relation, index| - range = relation.pluck('MIN(id)', 'MAX(id)').first + range = relation.pluck("MIN(id)", "MAX(id)").first BackgroundMigrationWorker.perform_in(index * 10.minutes, MIGRATION, range) end diff --git a/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb b/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb index 058f3a40817..0494d5c9f46 100644 --- a/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb +++ b/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb @@ -3,7 +3,7 @@ class RescheduleForkNetworkCreationCaller < ActiveRecord::Migration[4.2] DOWNTIME = false - MIGRATION = 'PopulateForkNetworksRange'.freeze + MIGRATION = "PopulateForkNetworksRange".freeze BATCH_SIZE = 100 DELAY_INTERVAL = 15.seconds @@ -12,11 +12,11 @@ class RescheduleForkNetworkCreationCaller < ActiveRecord::Migration[4.2] class ForkedProjectLink < ActiveRecord::Base include EachBatch - self.table_name = 'forked_project_links' + self.table_name = "forked_project_links" end def up - say 'Populating the `fork_networks` based on existing `forked_project_links`' + say "Populating the `fork_networks` based on existing `forked_project_links`" queue_background_migration_jobs_by_range_at_intervals(ForkedProjectLink, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE) end diff --git a/db/post_migrate/20171207150300_remove_project_labels_group_id_copy.rb b/db/post_migrate/20171207150300_remove_project_labels_group_id_copy.rb index 44273cebc9d..09ea611df4f 100644 --- a/db/post_migrate/20171207150300_remove_project_labels_group_id_copy.rb +++ b/db/post_migrate/20171207150300_remove_project_labels_group_id_copy.rb @@ -11,7 +11,7 @@ class RemoveProjectLabelsGroupIdCopy < ActiveRecord::Migration[4.2] def up # rubocop:disable Migration/UpdateColumnInBatches update_column_in_batches(:labels, :group_id, nil) do |table, query| - query.where(table[:type].eq('ProjectLabel').and(table[:group_id].not_eq(nil))) + query.where(table[:type].eq("ProjectLabel").and(table[:group_id].not_eq(nil))) end # rubocop:enable Migration/UpdateColumnInBatches end diff --git a/db/post_migrate/20171207150343_remove_soft_removed_objects.rb b/db/post_migrate/20171207150343_remove_soft_removed_objects.rb index 53707c67d36..81d6bb39dee 100644 --- a/db/post_migrate/20171207150343_remove_soft_removed_objects.rb +++ b/db/post_migrate/20171207150343_remove_soft_removed_objects.rb @@ -13,63 +13,63 @@ class RemoveSoftRemovedObjects < ActiveRecord::Migration[4.2] extend ActiveSupport::Concern included do - scope :soft_removed, -> { where('deleted_at IS NOT NULL') } + scope :soft_removed, -> { where("deleted_at IS NOT NULL") } end end class User < ActiveRecord::Base - self.table_name = 'users' + self.table_name = "users" include EachBatch end class Issue < ActiveRecord::Base - self.table_name = 'issues' + self.table_name = "issues" include EachBatch include SoftRemoved end class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' + self.table_name = "merge_requests" include EachBatch include SoftRemoved end class Namespace < ActiveRecord::Base - self.table_name = 'namespaces' + self.table_name = "namespaces" include EachBatch include SoftRemoved scope :soft_removed_personal, -> { soft_removed.where(type: nil) } - scope :soft_removed_group, -> { soft_removed.where(type: 'Group') } + scope :soft_removed_group, -> { soft_removed.where(type: "Group") } end class Route < ActiveRecord::Base - self.table_name = 'routes' + self.table_name = "routes" include EachBatch include SoftRemoved end class Project < ActiveRecord::Base - self.table_name = 'projects' + self.table_name = "projects" include EachBatch include SoftRemoved end class CiPipelineSchedule < ActiveRecord::Base - self.table_name = 'ci_pipeline_schedules' + self.table_name = "ci_pipeline_schedules" include EachBatch include SoftRemoved end class CiTrigger < ActiveRecord::Base - self.table_name = 'ci_triggers' + self.table_name = "ci_triggers" include EachBatch include SoftRemoved @@ -118,7 +118,7 @@ class RemoveSoftRemovedObjects < ActiveRecord::Migration[4.2] model.table_name, [:deleted_at, :id], name: index_name, - where: 'deleted_at IS NOT NULL' + where: "deleted_at IS NOT NULL" ) end end @@ -159,8 +159,8 @@ class RemoveSoftRemovedObjects < ActiveRecord::Migration[4.2] admin_id = id_for_admin_user unless admin_id - say 'Not scheduling soft removed groups for removal as no admin user ' \ - 'could be found. You will need to remove any such groups manually.' + say "Not scheduling soft removed groups for removal as no admin user " \ + "could be found. You will need to remove any such groups manually." return end @@ -189,11 +189,11 @@ class RemoveSoftRemovedObjects < ActiveRecord::Migration[4.2] def remove_personal_routes namespaces = Namespace.select(1) .soft_removed - .where('namespaces.type IS NULL') - .where('routes.source_type = ?', 'Namespace') - .where('routes.source_id = namespaces.id') + .where("namespaces.type IS NULL") + .where("routes.source_type = ?", "Namespace") + .where("routes.source_id = namespaces.id") - Route.where('EXISTS (?)', namespaces).each_batch do |batch| + Route.where("EXISTS (?)", namespaces).each_batch do |batch| batch.delete_all end end diff --git a/db/post_migrate/20171213160445_migrate_github_importer_advance_stage_sidekiq_queue.rb b/db/post_migrate/20171213160445_migrate_github_importer_advance_stage_sidekiq_queue.rb index 088c4b5d46b..99908709007 100644 --- a/db/post_migrate/20171213160445_migrate_github_importer_advance_stage_sidekiq_queue.rb +++ b/db/post_migrate/20171213160445_migrate_github_importer_advance_stage_sidekiq_queue.rb @@ -7,10 +7,10 @@ class MigrateGithubImporterAdvanceStageSidekiqQueue < ActiveRecord::Migration[4. DOWNTIME = false def up - sidekiq_queue_migrate 'github_importer_advance_stage', to: 'github_import_advance_stage' + sidekiq_queue_migrate "github_importer_advance_stage", to: "github_import_advance_stage" end def down - sidekiq_queue_migrate 'github_import_advance_stage', to: 'github_importer_advance_stage' + sidekiq_queue_migrate "github_import_advance_stage", to: "github_importer_advance_stage" end end diff --git a/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb b/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb index 1c81e56db55..901ef394963 100644 --- a/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb +++ b/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb @@ -12,12 +12,12 @@ class PostPopulateCanPushFromDeployKeysProjects < ActiveRecord::Migration[4.2] class DeploysKeyProject < ActiveRecord::Base include EachBatch - self.table_name = 'deploy_keys_projects' + self.table_name = "deploy_keys_projects" end def up DeploysKeyProject.each_batch(of: 10_000) do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first + start_id, end_id = batch.pluck("MIN(id), MAX(id)").first if Gitlab::Database.mysql? execute <<-EOF.strip_heredoc @@ -40,7 +40,7 @@ class PostPopulateCanPushFromDeployKeysProjects < ActiveRecord::Migration[4.2] def down DeploysKeyProject.each_batch(of: 10_000) do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first + start_id, end_id = batch.pluck("MIN(id), MAX(id)").first if Gitlab::Database.mysql? execute <<-EOF.strip_heredoc diff --git a/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb b/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb index 45ef75fdb98..6515574d10d 100644 --- a/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb +++ b/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb @@ -5,7 +5,7 @@ class NormalizeExternUidFromIdentities < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - MIGRATION = 'NormalizeLdapExternUidsRange'.freeze + MIGRATION = "NormalizeLdapExternUidsRange".freeze DELAY_INTERVAL = 10.seconds disable_ddl_transaction! @@ -13,7 +13,7 @@ class NormalizeExternUidFromIdentities < ActiveRecord::Migration[4.2] class Identity < ActiveRecord::Base include EachBatch - self.table_name = 'identities' + self.table_name = "identities" end def up diff --git a/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb b/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb index 6b5e6202688..4b5de82325d 100644 --- a/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb +++ b/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb @@ -9,11 +9,11 @@ class ScheduleIssuesClosedAtTypeChange < ActiveRecord::Migration[4.2] disable_ddl_transaction! class Issue < ActiveRecord::Base - self.table_name = 'issues' + self.table_name = "issues" include EachBatch def self.to_migrate - where('closed_at IS NOT NULL') + where("closed_at IS NOT NULL") end end @@ -40,6 +40,6 @@ class ScheduleIssuesClosedAtTypeChange < ActiveRecord::Migration[4.2] def migrate_column_type? # Some environments may have already executed the previous version of this # migration, thus we don't need to migrate those environments again. - column_for('issues', 'closed_at').type == :datetime + column_for("issues", "closed_at").type == :datetime end end diff --git a/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb b/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb index 0822aebc2c6..7247e17c49c 100644 --- a/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb +++ b/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb @@ -13,9 +13,9 @@ class ScheduleSetConfidentialNoteEventsOnWebhooks < ActiveRecord::Migration[4.2] relation = migration::WebHook.hooks_to_update queue_background_migration_jobs_by_range_at_intervals(relation, - migration_name, - INTERVAL, - batch_size: BATCH_SIZE) + migration_name, + INTERVAL, + batch_size: BATCH_SIZE) end def down diff --git a/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb b/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb index 98bbb34dda1..81c52538eca 100644 --- a/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb +++ b/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb @@ -13,9 +13,9 @@ class ScheduleSetConfidentialNoteEventsOnServices < ActiveRecord::Migration[4.2] relation = migration::Service.services_to_update queue_background_migration_jobs_by_range_at_intervals(relation, - migration_name, - INTERVAL, - batch_size: BATCH_SIZE) + migration_name, + INTERVAL, + batch_size: BATCH_SIZE) end def down diff --git a/db/post_migrate/20180202111106_remove_project_labels_group_id.rb b/db/post_migrate/20180202111106_remove_project_labels_group_id.rb index 31ec84f0d6a..0d19ac0f9e5 100644 --- a/db/post_migrate/20180202111106_remove_project_labels_group_id.rb +++ b/db/post_migrate/20180202111106_remove_project_labels_group_id.rb @@ -10,7 +10,7 @@ class RemoveProjectLabelsGroupId < ActiveRecord::Migration[4.2] def up update_column_in_batches(:labels, :group_id, nil) do |table, query| - query.where(table[:type].eq('ProjectLabel').and(table[:group_id].not_eq(nil))) + query.where(table[:type].eq("ProjectLabel").and(table[:group_id].not_eq(nil))) end end diff --git a/db/post_migrate/20180204200836_change_author_id_to_not_null_in_todos.rb b/db/post_migrate/20180204200836_change_author_id_to_not_null_in_todos.rb index 54b8a91fa47..96d34a11d9d 100644 --- a/db/post_migrate/20180204200836_change_author_id_to_not_null_in_todos.rb +++ b/db/post_migrate/20180204200836_change_author_id_to_not_null_in_todos.rb @@ -2,7 +2,7 @@ class ChangeAuthorIdToNotNullInTodos < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers class Todo < ActiveRecord::Base - self.table_name = 'todos' + self.table_name = "todos" include EachBatch end diff --git a/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb b/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb index f8badcac990..067a5a9fc64 100644 --- a/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb +++ b/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb @@ -4,11 +4,11 @@ class AddTmpPartialNullIndexToBuilds < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - add_concurrent_index(:ci_builds, :id, where: 'stage_id IS NULL', - name: 'tmp_id_partial_null_index') + add_concurrent_index(:ci_builds, :id, where: "stage_id IS NULL", + name: "tmp_id_partial_null_index") end def down - remove_concurrent_index_by_name(:ci_builds, 'tmp_id_partial_null_index') + remove_concurrent_index_by_name(:ci_builds, "tmp_id_partial_null_index") end end diff --git a/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb b/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb index 2444df881b8..cd1c2c100f1 100644 --- a/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb +++ b/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb @@ -4,11 +4,11 @@ class RemoveTmpPartialNullIndexFromBuilds < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - remove_concurrent_index_by_name(:ci_builds, 'tmp_id_partial_null_index') + remove_concurrent_index_by_name(:ci_builds, "tmp_id_partial_null_index") end def down - add_concurrent_index(:ci_builds, :id, where: 'stage_id IS NULL', - name: 'tmp_id_partial_null_index') + add_concurrent_index(:ci_builds, :id, where: "stage_id IS NULL", + name: "tmp_id_partial_null_index") end end diff --git a/db/post_migrate/20180216121020_fill_pages_domain_verification_code.rb b/db/post_migrate/20180216121020_fill_pages_domain_verification_code.rb index dae43ee14df..534e89b4d0e 100644 --- a/db/post_migrate/20180216121020_fill_pages_domain_verification_code.rb +++ b/db/post_migrate/20180216121020_fill_pages_domain_verification_code.rb @@ -9,7 +9,7 @@ class FillPagesDomainVerificationCode < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - PagesDomain.where(verification_code: [nil, '']).each_batch do |relation| + PagesDomain.where(verification_code: [nil, ""]).each_batch do |relation| connection.execute(set_codes_sql(relation)) # Sleep 2 minutes between batches to not overload the DB with dead tuples @@ -35,7 +35,7 @@ class FillPagesDomainVerificationCode < ActiveRecord::Migration[4.2] CASE id #{whens.join("\n")} END - WHERE id IN(#{ids.join(',')}) + WHERE id IN(#{ids.join(",")}) SQL end end diff --git a/db/post_migrate/20180220150310_remove_empty_extern_uid_auth0_identities.rb b/db/post_migrate/20180220150310_remove_empty_extern_uid_auth0_identities.rb index 86ef333685e..941069657ff 100644 --- a/db/post_migrate/20180220150310_remove_empty_extern_uid_auth0_identities.rb +++ b/db/post_migrate/20180220150310_remove_empty_extern_uid_auth0_identities.rb @@ -6,7 +6,7 @@ class RemoveEmptyExternUidAuth0Identities < ActiveRecord::Migration[4.2] disable_ddl_transaction! class Identity < ActiveRecord::Base - self.table_name = 'identities' + self.table_name = "identities" include EachBatch end @@ -17,7 +17,7 @@ class RemoveEmptyExternUidAuth0Identities < ActiveRecord::Migration[4.2] end def broken_auth0_identities - Identity.where(provider: 'auth0', extern_uid: [nil, '']) + Identity.where(provider: "auth0", extern_uid: [nil, ""]) end def down diff --git a/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb b/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb index fa332fd5c70..9dac79b88c5 100644 --- a/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb +++ b/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb @@ -1,4 +1,4 @@ -require_relative '../migrate/20180223120443_create_user_interacted_projects_table.rb' +require_relative "../migrate/20180223120443_create_user_interacted_projects_table.rb" # rubocop:disable AddIndex # rubocop:disable AddConcurrentForeignKey class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2] @@ -7,7 +7,7 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2] # Set this constant to true if this migration requires downtime. DOWNTIME = false - UNIQUE_INDEX_NAME = 'index_user_interacted_projects_on_project_id_and_user_id' + UNIQUE_INDEX_NAME = "index_user_interacted_projects_on_project_id_and_user_id" disable_ddl_transaction! @@ -50,7 +50,7 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2] SLEEP_TIME = 5 def up - with_index(:events, [:author_id, :project_id], name: 'events_user_interactions_temp', where: 'project_id IS NOT NULL') do + with_index(:events, [:author_id, :project_id], name: "events_user_interactions_temp", where: "project_id IS NOT NULL") do insert_missing_records # Do this once without lock to speed up the second invocation @@ -84,12 +84,12 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2] begin Rails.logger.info "Building user_interacted_projects table, batch ##{iteration}" result = execute <<~SQL - INSERT INTO user_interacted_projects (user_id, project_id) - SELECT e.user_id, e.project_id - FROM (SELECT DISTINCT author_id AS user_id, project_id FROM events WHERE project_id IS NOT NULL) AS e - LEFT JOIN user_interacted_projects ucp USING (user_id, project_id) - WHERE ucp.user_id IS NULL - LIMIT #{BATCH_SIZE} + INSERT INTO user_interacted_projects (user_id, project_id) + SELECT e.user_id, e.project_id + FROM (SELECT DISTINCT author_id AS user_id, project_id FROM events WHERE project_id IS NOT NULL) AS e + LEFT JOIN user_interacted_projects ucp USING (user_id, project_id) + WHERE ucp.user_id IS NULL + LIMIT #{BATCH_SIZE} SQL iteration += 1 records += result.cmd_tuples diff --git a/db/post_migrate/20180301084653_change_project_namespace_id_not_null.rb b/db/post_migrate/20180301084653_change_project_namespace_id_not_null.rb index 62a239b0e7c..d149076f382 100644 --- a/db/post_migrate/20180301084653_change_project_namespace_id_not_null.rb +++ b/db/post_migrate/20180301084653_change_project_namespace_id_not_null.rb @@ -5,7 +5,7 @@ class ChangeProjectNamespaceIdNotNull < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers class Project < ActiveRecord::Base - self.table_name = 'projects' + self.table_name = "projects" include EachBatch end diff --git a/db/post_migrate/20180306074045_migrate_create_trace_artifact_sidekiq_queue.rb b/db/post_migrate/20180306074045_migrate_create_trace_artifact_sidekiq_queue.rb index fc74f6f1712..56a749f1db5 100644 --- a/db/post_migrate/20180306074045_migrate_create_trace_artifact_sidekiq_queue.rb +++ b/db/post_migrate/20180306074045_migrate_create_trace_artifact_sidekiq_queue.rb @@ -4,10 +4,10 @@ class MigrateCreateTraceArtifactSidekiqQueue < ActiveRecord::Migration[4.2] DOWNTIME = false def up - sidekiq_queue_migrate 'pipeline_default:create_trace_artifact', to: 'pipeline_background:archive_trace' + sidekiq_queue_migrate "pipeline_default:create_trace_artifact", to: "pipeline_background:archive_trace" end def down - sidekiq_queue_migrate 'pipeline_background:archive_trace', to: 'pipeline_default:create_trace_artifact' + sidekiq_queue_migrate "pipeline_background:archive_trace", to: "pipeline_default:create_trace_artifact" end end diff --git a/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb b/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb index 53918250b4c..0552ab44ae1 100644 --- a/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb +++ b/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb @@ -8,7 +8,7 @@ class AddPathIndexToRedirectRoutes < ActiveRecord::Migration[4.2] DOWNTIME = false disable_ddl_transaction! - INDEX_NAME = 'index_redirect_routes_on_path_unique_text_pattern_ops' + INDEX_NAME = "index_redirect_routes_on_path_unique_text_pattern_ops" # Indexing on LOWER(path) varchar_pattern_ops speeds up the LIKE query in # RedirectRoute.matching_path_and_descendants diff --git a/db/post_migrate/20180307012445_migrate_update_head_pipeline_for_merge_request_sidekiq_queue.rb b/db/post_migrate/20180307012445_migrate_update_head_pipeline_for_merge_request_sidekiq_queue.rb index 372c04429c7..7cec496f8c8 100644 --- a/db/post_migrate/20180307012445_migrate_update_head_pipeline_for_merge_request_sidekiq_queue.rb +++ b/db/post_migrate/20180307012445_migrate_update_head_pipeline_for_merge_request_sidekiq_queue.rb @@ -4,12 +4,12 @@ class MigrateUpdateHeadPipelineForMergeRequestSidekiqQueue < ActiveRecord::Migra DOWNTIME = false def up - sidekiq_queue_migrate 'pipeline_default:update_head_pipeline_for_merge_request', - to: 'pipeline_processing:update_head_pipeline_for_merge_request' + sidekiq_queue_migrate "pipeline_default:update_head_pipeline_for_merge_request", + to: "pipeline_processing:update_head_pipeline_for_merge_request" end def down - sidekiq_queue_migrate 'pipeline_processing:update_head_pipeline_for_merge_request', - to: 'pipeline_default:update_head_pipeline_for_merge_request' + sidekiq_queue_migrate "pipeline_processing:update_head_pipeline_for_merge_request", + to: "pipeline_default:update_head_pipeline_for_merge_request" end end diff --git a/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb b/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb index 213d97b71f7..a5c64d7bdd5 100644 --- a/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb +++ b/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb @@ -6,23 +6,23 @@ class RescheduleBuildsStagesMigration < ActiveRecord::Migration[4.2] # DOWNTIME = false - MIGRATION = 'MigrateBuildStage'.freeze + MIGRATION = "MigrateBuildStage".freeze BATCH_SIZE = 500 disable_ddl_transaction! class Build < ActiveRecord::Base include EachBatch - self.table_name = 'ci_builds' + self.table_name = "ci_builds" end def up disable_statement_timeout do - Build.where('stage_id IS NULL').tap do |relation| + Build.where("stage_id IS NULL").tap do |relation| queue_background_migration_jobs_by_range_at_intervals(relation, - MIGRATION, - 5.minutes, - batch_size: BATCH_SIZE) + MIGRATION, + 5.minutes, + batch_size: BATCH_SIZE) end end end diff --git a/db/post_migrate/20180420080616_schedule_stages_index_migration.rb b/db/post_migrate/20180420080616_schedule_stages_index_migration.rb index 2d72e75393f..4995fe1624b 100644 --- a/db/post_migrate/20180420080616_schedule_stages_index_migration.rb +++ b/db/post_migrate/20180420080616_schedule_stages_index_migration.rb @@ -2,23 +2,23 @@ class ScheduleStagesIndexMigration < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - MIGRATION = 'MigrateStageIndex'.freeze + MIGRATION = "MigrateStageIndex".freeze BATCH_SIZE = 10000 disable_ddl_transaction! class Stage < ActiveRecord::Base include EachBatch - self.table_name = 'ci_stages' + self.table_name = "ci_stages" end def up disable_statement_timeout do Stage.all.tap do |relation| queue_background_migration_jobs_by_range_at_intervals(relation, - MIGRATION, - 5.minutes, - batch_size: BATCH_SIZE) + MIGRATION, + 5.minutes, + batch_size: BATCH_SIZE) end end end diff --git a/db/post_migrate/20180424151928_fill_file_store.rb b/db/post_migrate/20180424151928_fill_file_store.rb index 45fa10c9550..a92baf50e19 100644 --- a/db/post_migrate/20180424151928_fill_file_store.rb +++ b/db/post_migrate/20180424151928_fill_file_store.rb @@ -7,32 +7,32 @@ class FillFileStore < ActiveRecord::Migration[4.2] class JobArtifact < ActiveRecord::Base include EachBatch - self.table_name = 'ci_job_artifacts' + self.table_name = "ci_job_artifacts" BATCH_SIZE = 10_000 def self.params_for_background_migration - yield self.where(file_store: nil), 'FillFileStoreJobArtifact', 5.minutes, BATCH_SIZE + yield where(file_store: nil), "FillFileStoreJobArtifact", 5.minutes, BATCH_SIZE end end class LfsObject < ActiveRecord::Base include EachBatch - self.table_name = 'lfs_objects' + self.table_name = "lfs_objects" BATCH_SIZE = 10_000 def self.params_for_background_migration - yield self.where(file_store: nil), 'FillFileStoreLfsObject', 5.minutes, BATCH_SIZE + yield where(file_store: nil), "FillFileStoreLfsObject", 5.minutes, BATCH_SIZE end end class Upload < ActiveRecord::Base include EachBatch - self.table_name = 'uploads' + self.table_name = "uploads" self.inheritance_column = :_type_disabled # Disable STI BATCH_SIZE = 10_000 def self.params_for_background_migration - yield self.where(store: nil), 'FillStoreUpload', 5.minutes, BATCH_SIZE + yield where(store: nil), "FillStoreUpload", 5.minutes, BATCH_SIZE end end diff --git a/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb b/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb index b82ee3569c9..2d53e193226 100644 --- a/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb +++ b/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb @@ -3,8 +3,8 @@ class MigrateImportAttributesDataFromProjectsToProjectMirrorData < ActiveRecord: DOWNTIME = false - UP_MIGRATION = 'PopulateImportState'.freeze - DOWN_MIGRATION = 'RollbackImportStateData'.freeze + UP_MIGRATION = "PopulateImportState".freeze + DOWN_MIGRATION = "RollbackImportStateData".freeze BATCH_SIZE = 1000 DELAY_INTERVAL = 5.minutes @@ -14,13 +14,13 @@ class MigrateImportAttributesDataFromProjectsToProjectMirrorData < ActiveRecord: class Project < ActiveRecord::Base include EachBatch - self.table_name = 'projects' + self.table_name = "projects" end class ProjectImportState < ActiveRecord::Base include EachBatch - self.table_name = 'project_mirror_data' + self.table_name = "project_mirror_data" end def up diff --git a/db/post_migrate/20180511174224_add_unique_constraint_to_project_features_project_id.rb b/db/post_migrate/20180511174224_add_unique_constraint_to_project_features_project_id.rb index a526001a91e..5384b865a35 100644 --- a/db/post_migrate/20180511174224_add_unique_constraint_to_project_features_project_id.rb +++ b/db/post_migrate/20180511174224_add_unique_constraint_to_project_features_project_id.rb @@ -6,7 +6,7 @@ class AddUniqueConstraintToProjectFeaturesProjectId < ActiveRecord::Migration[4. disable_ddl_transaction! class ProjectFeature < ActiveRecord::Base - self.table_name = 'project_features' + self.table_name = "project_features" include EachBatch end @@ -14,29 +14,29 @@ class AddUniqueConstraintToProjectFeaturesProjectId < ActiveRecord::Migration[4. def up remove_duplicates - add_concurrent_index :project_features, :project_id, unique: true, name: 'index_project_features_on_project_id_unique' - remove_concurrent_index_by_name :project_features, 'index_project_features_on_project_id' - rename_index :project_features, 'index_project_features_on_project_id_unique', 'index_project_features_on_project_id' + add_concurrent_index :project_features, :project_id, unique: true, name: "index_project_features_on_project_id_unique" + remove_concurrent_index_by_name :project_features, "index_project_features_on_project_id" + rename_index :project_features, "index_project_features_on_project_id_unique", "index_project_features_on_project_id" end def down - rename_index :project_features, 'index_project_features_on_project_id', 'index_project_features_on_project_id_old' + rename_index :project_features, "index_project_features_on_project_id", "index_project_features_on_project_id_old" add_concurrent_index :project_features, :project_id - remove_concurrent_index_by_name :project_features, 'index_project_features_on_project_id_old' + remove_concurrent_index_by_name :project_features, "index_project_features_on_project_id_old" end private def remove_duplicates features = ProjectFeature - .select('MAX(id) AS max, COUNT(id), project_id') - .group(:project_id) - .having('COUNT(id) > 1') + .select("MAX(id) AS max, COUNT(id), project_id") + .group(:project_id) + .having("COUNT(id) > 1") features.each do |feature| ProjectFeature - .where(project_id: feature['project_id']) - .where('id <> ?', feature['max']) + .where(project_id: feature["project_id"]) + .where("id <> ?", feature["max"]) .each_batch { |batch| batch.delete_all } end end diff --git a/db/post_migrate/20180512061621_add_not_null_constraint_to_project_features_project_id.rb b/db/post_migrate/20180512061621_add_not_null_constraint_to_project_features_project_id.rb index e3abbc039e8..c0e31711359 100644 --- a/db/post_migrate/20180512061621_add_not_null_constraint_to_project_features_project_id.rb +++ b/db/post_migrate/20180512061621_add_not_null_constraint_to_project_features_project_id.rb @@ -6,7 +6,7 @@ class AddNotNullConstraintToProjectFeaturesProjectId < ActiveRecord::Migration[4 class ProjectFeature < ActiveRecord::Base include EachBatch - self.table_name = 'project_features' + self.table_name = "project_features" end def up diff --git a/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb b/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb index 39666a0cd2a..d472f48e9dd 100644 --- a/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb +++ b/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb @@ -3,13 +3,13 @@ class MigrateRemainingMrMetricsPopulatingBackgroundMigration < ActiveRecord::Mig DOWNTIME = false BATCH_SIZE = 5_000 - MIGRATION = 'PopulateMergeRequestMetricsWithEventsData' + MIGRATION = "PopulateMergeRequestMetricsWithEventsData" DELAY_INTERVAL = 10.minutes disable_ddl_transaction! class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' + self.table_name = "merge_requests" include ::EachBatch end @@ -34,9 +34,9 @@ class MigrateRemainingMrMetricsPopulatingBackgroundMigration < ActiveRecord::Mig # so this should take ~14 hours for all background migrations to complete. # queue_background_migration_jobs_by_range_at_intervals(relation, - MIGRATION, - DELAY_INTERVAL, - batch_size: BATCH_SIZE) + MIGRATION, + DELAY_INTERVAL, + batch_size: BATCH_SIZE) end def down diff --git a/db/post_migrate/20180529152628_schedule_to_archive_legacy_traces.rb b/db/post_migrate/20180529152628_schedule_to_archive_legacy_traces.rb index 6246f6afab0..84f6d0ccfd9 100644 --- a/db/post_migrate/20180529152628_schedule_to_archive_legacy_traces.rb +++ b/db/post_migrate/20180529152628_schedule_to_archive_legacy_traces.rb @@ -3,21 +3,21 @@ class ScheduleToArchiveLegacyTraces < ActiveRecord::Migration[4.2] DOWNTIME = false BATCH_SIZE = 5000 - BACKGROUND_MIGRATION_CLASS = 'ArchiveLegacyTraces' + BACKGROUND_MIGRATION_CLASS = "ArchiveLegacyTraces" disable_ddl_transaction! class Build < ActiveRecord::Base include EachBatch - self.table_name = 'ci_builds' + self.table_name = "ci_builds" self.inheritance_column = :_type_disabled # Disable STI - scope :type_build, -> { where(type: 'Ci::Build') } + scope :type_build, -> { where(type: "Ci::Build") } scope :finished, -> { where(status: [:success, :failed, :canceled]) } scope :without_archived_trace, -> do - where('NOT EXISTS (SELECT 1 FROM ci_job_artifacts WHERE ci_builds.id = ci_job_artifacts.job_id AND ci_job_artifacts.file_type = 3)') + where("NOT EXISTS (SELECT 1 FROM ci_job_artifacts WHERE ci_builds.id = ci_job_artifacts.job_id AND ci_job_artifacts.file_type = 3)") end end @@ -26,7 +26,8 @@ class ScheduleToArchiveLegacyTraces < ActiveRecord::Migration[4.2] ::ScheduleToArchiveLegacyTraces::Build.type_build.finished.without_archived_trace, BACKGROUND_MIGRATION_CLASS, 5.minutes, - batch_size: BATCH_SIZE) + batch_size: BATCH_SIZE + ) end def down diff --git a/db/post_migrate/20180603190921_migrate_object_storage_upload_sidekiq_queue.rb b/db/post_migrate/20180603190921_migrate_object_storage_upload_sidekiq_queue.rb index bc7c3eb5385..bf2429f7d8e 100644 --- a/db/post_migrate/20180603190921_migrate_object_storage_upload_sidekiq_queue.rb +++ b/db/post_migrate/20180603190921_migrate_object_storage_upload_sidekiq_queue.rb @@ -6,7 +6,7 @@ class MigrateObjectStorageUploadSidekiqQueue < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - sidekiq_queue_migrate 'object_storage_upload', to: 'object_storage:object_storage_background_move' + sidekiq_queue_migrate "object_storage_upload", to: "object_storage:object_storage_background_move" end def down diff --git a/db/post_migrate/20180604123514_cleanup_stages_position_migration.rb b/db/post_migrate/20180604123514_cleanup_stages_position_migration.rb index 326cdfa27c3..1d2bdd7666c 100644 --- a/db/post_migrate/20180604123514_cleanup_stages_position_migration.rb +++ b/db/post_migrate/20180604123514_cleanup_stages_position_migration.rb @@ -2,21 +2,21 @@ class CleanupStagesPositionMigration < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - TMP_INDEX_NAME = 'tmp_id_stage_position_partial_null_index'.freeze + TMP_INDEX_NAME = "tmp_id_stage_position_partial_null_index".freeze disable_ddl_transaction! class Stages < ActiveRecord::Base include EachBatch - self.table_name = 'ci_stages' + self.table_name = "ci_stages" end def up disable_statement_timeout do - Gitlab::BackgroundMigration.steal('MigrateStageIndex') + Gitlab::BackgroundMigration.steal("MigrateStageIndex") unless index_exists_by_name?(:ci_stages, TMP_INDEX_NAME) - add_concurrent_index(:ci_stages, :id, where: 'position IS NULL', name: TMP_INDEX_NAME) + add_concurrent_index(:ci_stages, :id, where: "position IS NULL", name: TMP_INDEX_NAME) end migratable = <<~SQL diff --git a/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb b/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb index 73f6a3a2a43..90995afde1b 100644 --- a/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb +++ b/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb @@ -2,8 +2,8 @@ class EnqueueDeleteDiffFilesWorkers < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - SCHEDULER = 'ScheduleDiffFilesDeletion'.freeze - TMP_INDEX = 'tmp_partial_diff_id_with_files_index'.freeze + SCHEDULER = "ScheduleDiffFilesDeletion".freeze + TMP_INDEX = "tmp_partial_diff_id_with_files_index".freeze disable_ddl_transaction! diff --git a/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb b/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb index 3d3d49e7564..7f0e16ea658 100644 --- a/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb +++ b/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb @@ -3,21 +3,21 @@ class EnqueueFixCrossProjectLabelLinks < ActiveRecord::Migration[4.2] DOWNTIME = false BATCH_SIZE = 100 - MIGRATION = 'FixCrossProjectLabelLinks' + MIGRATION = "FixCrossProjectLabelLinks" DELAY_INTERVAL = 5.minutes disable_ddl_transaction! class Label < ActiveRecord::Base - self.table_name = 'labels' + self.table_name = "labels" end class Namespace < ActiveRecord::Base - self.table_name = 'namespaces' + self.table_name = "namespaces" include ::EachBatch - default_scope { where(type: 'Group', id: Label.where(type: 'GroupLabel').select('distinct group_id')) } + default_scope { where(type: "Group", id: Label.where(type: "GroupLabel").select("distinct group_id")) } end def up diff --git a/db/post_migrate/20180704145007_update_project_indexes.rb b/db/post_migrate/20180704145007_update_project_indexes.rb index 0a82f4535a0..323714c96f5 100644 --- a/db/post_migrate/20180704145007_update_project_indexes.rb +++ b/db/post_migrate/20180704145007_update_project_indexes.rb @@ -5,7 +5,7 @@ class UpdateProjectIndexes < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - NEW_INDEX_NAME = 'idx_project_repository_check_partial' + NEW_INDEX_NAME = "idx_project_repository_check_partial" disable_ddl_transaction! @@ -13,8 +13,7 @@ class UpdateProjectIndexes < ActiveRecord::Migration[4.2] add_concurrent_index(:projects, [:repository_storage, :created_at], name: NEW_INDEX_NAME, - where: 'last_repository_check_at IS NULL' - ) + where: "last_repository_check_at IS NULL") end def down diff --git a/db/post_migrate/20180706223200_populate_site_statistics.rb b/db/post_migrate/20180706223200_populate_site_statistics.rb index 896965b708f..4bbecf36140 100644 --- a/db/post_migrate/20180706223200_populate_site_statistics.rb +++ b/db/post_migrate/20180706223200_populate_site_statistics.rb @@ -7,13 +7,13 @@ class PopulateSiteStatistics < ActiveRecord::Migration[4.2] def up transaction do - execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967 + 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 repositories_count = (SELECT COUNT(*) FROM projects)") end transaction do - execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967 + 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 diff --git a/db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb b/db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb index 440868005bb..20d012c5fac 100644 --- a/db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb +++ b/db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class DeleteInconsistentInternalIdRecords < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers @@ -14,18 +15,18 @@ class DeleteInconsistentInternalIdRecords < ActiveRecord::Migration[4.2] def up disable_statement_timeout do - delete_internal_id_records('issues', 'project_id') - delete_internal_id_records('merge_requests', 'project_id', 'target_project_id') - delete_internal_id_records('deployments', 'project_id') - delete_internal_id_records('milestones', 'project_id') - delete_internal_id_records('milestones', 'namespace_id', 'group_id') - delete_internal_id_records('ci_pipelines', 'project_id') + delete_internal_id_records("issues", "project_id") + delete_internal_id_records("merge_requests", "project_id", "target_project_id") + delete_internal_id_records("deployments", "project_id") + delete_internal_id_records("milestones", "project_id") + delete_internal_id_records("milestones", "namespace_id", "group_id") + delete_internal_id_records("ci_pipelines", "project_id") end end class InternalId < ActiveRecord::Base - self.table_name = 'internal_ids' - enum usage: { issues: 0, merge_requests: 1, deployments: 2, milestones: 3, epics: 4, ci_pipelines: 5 } + self.table_name = "internal_ids" + enum usage: {issues: 0, merge_requests: 1, deployments: 2, milestones: 3, epics: 4, ci_pipelines: 5} end private diff --git a/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb b/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb index 363219da539..64491a063c9 100644 --- a/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb +++ b/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb @@ -10,7 +10,7 @@ class MigrateNullWikiAccessLevels < ActiveRecord::Migration[4.2] class ProjectFeature < ActiveRecord::Base include EachBatch - self.table_name = 'project_features' + self.table_name = "project_features" end def up @@ -20,7 +20,7 @@ class MigrateNullWikiAccessLevels < ActiveRecord::Migration[4.2] # 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("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 diff --git a/db/post_migrate/20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb b/db/post_migrate/20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb index 6b0d1ef0d0c..0e0a26fed17 100644 --- a/db/post_migrate/20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb +++ b/db/post_migrate/20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb @@ -2,7 +2,7 @@ class MigrateLegacyArtifactsToJobArtifacts < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - MIGRATION = 'MigrateLegacyArtifacts'.freeze + MIGRATION = "MigrateLegacyArtifacts".freeze BATCH_SIZE = 100 disable_ddl_transaction! @@ -10,7 +10,7 @@ class MigrateLegacyArtifactsToJobArtifacts < ActiveRecord::Migration[4.2] class Build < ActiveRecord::Base include EachBatch - self.table_name = 'ci_builds' + self.table_name = "ci_builds" self.inheritance_column = :_type_disabled scope :with_legacy_artifacts, -> { where("artifacts_file <> ''") } @@ -20,9 +20,9 @@ class MigrateLegacyArtifactsToJobArtifacts < ActiveRecord::Migration[4.2] MigrateLegacyArtifactsToJobArtifacts::Build .with_legacy_artifacts.tap do |relation| queue_background_migration_jobs_by_range_at_intervals(relation, - MIGRATION, - 5.minutes, - batch_size: BATCH_SIZE) + MIGRATION, + 5.minutes, + batch_size: BATCH_SIZE) end end diff --git a/db/post_migrate/20180816193530_rename_login_root_namespaces.rb b/db/post_migrate/20180816193530_rename_login_root_namespaces.rb index 70db8f46d05..dc3c89a36d6 100644 --- a/db/post_migrate/20180816193530_rename_login_root_namespaces.rb +++ b/db/post_migrate/20180816193530_rename_login_root_namespaces.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class RenameLoginRootNamespaces < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers include Gitlab::Database::RenameReservedPathsMigration::V1 @@ -10,7 +11,7 @@ class RenameLoginRootNamespaces < ActiveRecord::Migration[4.2] # We're taking over the /login namespace as part of a fix for the Jira integration def up disable_statement_timeout do - rename_root_paths 'login' + rename_root_paths "login" end end diff --git a/db/post_migrate/20180826111825_recalculate_site_statistics.rb b/db/post_migrate/20180826111825_recalculate_site_statistics.rb index 6d27eca38e3..9b2e14edfd5 100644 --- a/db/post_migrate/20180826111825_recalculate_site_statistics.rb +++ b/db/post_migrate/20180826111825_recalculate_site_statistics.rb @@ -9,13 +9,13 @@ class RecalculateSiteStatistics < ActiveRecord::Migration[4.2] def up transaction do - execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967 + 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 repositories_count = (SELECT COUNT(*) FROM projects)") end transaction do - execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967 + 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 diff --git a/db/post_migrate/20180906051323_remove_orphaned_label_links.rb b/db/post_migrate/20180906051323_remove_orphaned_label_links.rb index a474aaf534c..a741dcb053a 100644 --- a/db/post_migrate/20180906051323_remove_orphaned_label_links.rb +++ b/db/post_migrate/20180906051323_remove_orphaned_label_links.rb @@ -8,11 +8,11 @@ class RemoveOrphanedLabelLinks < ActiveRecord::Migration[4.2] disable_ddl_transaction! class LabelLinks < ActiveRecord::Base - self.table_name = 'label_links' + self.table_name = "label_links" include EachBatch def self.orphaned - where('NOT EXISTS ( SELECT 1 FROM labels WHERE labels.id = label_links.label_id )') + where("NOT EXISTS ( SELECT 1 FROM labels WHERE labels.id = label_links.label_id )") end end diff --git a/db/post_migrate/20180913051323_consume_remaining_diff_files_deletion_jobs.rb b/db/post_migrate/20180913051323_consume_remaining_diff_files_deletion_jobs.rb index 2c266a4695b..b5944f48727 100644 --- a/db/post_migrate/20180913051323_consume_remaining_diff_files_deletion_jobs.rb +++ b/db/post_migrate/20180913051323_consume_remaining_diff_files_deletion_jobs.rb @@ -7,8 +7,8 @@ class ConsumeRemainingDiffFilesDeletionJobs < ActiveRecord::Migration[4.2] disable_ddl_transaction! - MIGRATION = 'ScheduleDiffFilesDeletion'.freeze - TMP_INDEX = 'tmp_partial_diff_id_with_files_index'.freeze + MIGRATION = "ScheduleDiffFilesDeletion" + TMP_INDEX = "tmp_partial_diff_id_with_files_index" def up # Perform any ongoing background migration that might still be scheduled. diff --git a/db/post_migrate/20180913142237_schedule_digest_personal_access_tokens.rb b/db/post_migrate/20180913142237_schedule_digest_personal_access_tokens.rb index 951cb3b088c..bdab6e6cf06 100644 --- a/db/post_migrate/20180913142237_schedule_digest_personal_access_tokens.rb +++ b/db/post_migrate/20180913142237_schedule_digest_personal_access_tokens.rb @@ -4,7 +4,7 @@ class ScheduleDigestPersonalAccessTokens < ActiveRecord::Migration[4.2] DOWNTIME = false BATCH_SIZE = 10_000 - MIGRATION = 'DigestColumn' + MIGRATION = "DigestColumn" DELAY_INTERVAL = 5.minutes.to_i disable_ddl_transaction! @@ -12,13 +12,13 @@ class ScheduleDigestPersonalAccessTokens < ActiveRecord::Migration[4.2] class PersonalAccessToken < ActiveRecord::Base include EachBatch - self.table_name = 'personal_access_tokens' + self.table_name = "personal_access_tokens" end def up - PersonalAccessToken.where('token is NOT NULL').each_batch(of: BATCH_SIZE) do |batch, index| - range = batch.pluck('MIN(id)', 'MAX(id)').first - BackgroundMigrationWorker.perform_in(index * DELAY_INTERVAL, MIGRATION, ['PersonalAccessToken', :token, :token_digest, *range]) + PersonalAccessToken.where("token is NOT NULL").each_batch(of: BATCH_SIZE) do |batch, index| + range = batch.pluck("MIN(id)", "MAX(id)").first + BackgroundMigrationWorker.perform_in(index * DELAY_INTERVAL, MIGRATION, ["PersonalAccessToken", :token, :token_digest, *range]) end end diff --git a/db/post_migrate/20180914162043_encrypt_web_hooks_columns.rb b/db/post_migrate/20180914162043_encrypt_web_hooks_columns.rb index ef864f490bb..2752c7286bf 100644 --- a/db/post_migrate/20180914162043_encrypt_web_hooks_columns.rb +++ b/db/post_migrate/20180914162043_encrypt_web_hooks_columns.rb @@ -7,7 +7,7 @@ class EncryptWebHooksColumns < ActiveRecord::Migration[4.2] BATCH_SIZE = 10000 RANGE_SIZE = 100 - MIGRATION = 'EncryptColumns' + MIGRATION = "EncryptColumns" COLUMNS = [:token, :url] WebHook = ::Gitlab::BackgroundMigration::Models::EncryptColumns::WebHook @@ -19,7 +19,7 @@ class EncryptWebHooksColumns < ActiveRecord::Migration[4.2] delay = index * 2.minutes relation.each_batch(of: RANGE_SIZE) do |relation| - range = relation.pluck('MIN(id)', 'MAX(id)').first + range = relation.pluck("MIN(id)", "MAX(id)").first args = [WebHook, COLUMNS, *range] BackgroundMigrationWorker.perform_in(delay, MIGRATION, args) diff --git a/db/post_migrate/20180914201132_remove_sidekiq_throttling_from_application_settings.rb b/db/post_migrate/20180914201132_remove_sidekiq_throttling_from_application_settings.rb index 2c007ec395d..0532a6742b9 100644 --- a/db/post_migrate/20180914201132_remove_sidekiq_throttling_from_application_settings.rb +++ b/db/post_migrate/20180914201132_remove_sidekiq_throttling_from_application_settings.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. diff --git a/db/post_migrate/20180916014356_populate_external_pipeline_source.rb b/db/post_migrate/20180916014356_populate_external_pipeline_source.rb index a3d2df1f2bd..b70da3d4c7b 100644 --- a/db/post_migrate/20180916014356_populate_external_pipeline_source.rb +++ b/db/post_migrate/20180916014356_populate_external_pipeline_source.rb @@ -8,22 +8,22 @@ class PopulateExternalPipelineSource < ActiveRecord::Migration[4.2] # Set this constant to true if this migration requires downtime. DOWNTIME = false - MIGRATION = 'PopulateExternalPipelineSource'.freeze + MIGRATION = "PopulateExternalPipelineSource" BATCH_SIZE = 500 disable_ddl_transaction! class Pipeline < ActiveRecord::Base include EachBatch - self.table_name = 'ci_pipelines' + self.table_name = "ci_pipelines" end def up Pipeline.where(source: nil).tap do |relation| queue_background_migration_jobs_by_range_at_intervals(relation, - MIGRATION, - 5.minutes, - batch_size: BATCH_SIZE) + MIGRATION, + 5.minutes, + batch_size: BATCH_SIZE) end end diff --git a/db/post_migrate/20180917172041_remove_wikis_count_from_site_statistics.rb b/db/post_migrate/20180917172041_remove_wikis_count_from_site_statistics.rb index 3b8300dabeb..61d82fb7798 100644 --- a/db/post_migrate/20180917172041_remove_wikis_count_from_site_statistics.rb +++ b/db/post_migrate/20180917172041_remove_wikis_count_from_site_statistics.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class RemoveWikisCountFromSiteStatistics < ActiveRecord::Migration[4.2] def change remove_column :site_statistics, :wikis_count, :integer diff --git a/db/post_migrate/20181008145341_steal_encrypt_columns.rb b/db/post_migrate/20181008145341_steal_encrypt_columns.rb index 4102643ba13..5beef84d829 100644 --- a/db/post_migrate/20181008145341_steal_encrypt_columns.rb +++ b/db/post_migrate/20181008145341_steal_encrypt_columns.rb @@ -6,7 +6,7 @@ class StealEncryptColumns < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up - Gitlab::BackgroundMigration.steal('EncryptColumns') + Gitlab::BackgroundMigration.steal("EncryptColumns") end def down diff --git a/db/post_migrate/20181008200441_remove_circuit_breaker.rb b/db/post_migrate/20181008200441_remove_circuit_breaker.rb index 378692e8886..88ebf11fac8 100644 --- a/db/post_migrate/20181008200441_remove_circuit_breaker.rb +++ b/db/post_migrate/20181008200441_remove_circuit_breaker.rb @@ -13,7 +13,7 @@ class RemoveCircuitBreaker < ActiveRecord::Migration[4.2] circuitbreaker_failure_reset_time: 1800, circuitbreaker_storage_timeout: 15, circuitbreaker_access_retries: 3, - circuitbreaker_check_interval: 1 + circuitbreaker_check_interval: 1, }.freeze def up diff --git a/db/post_migrate/20181010133639_backfill_store_project_full_path_in_repo.rb b/db/post_migrate/20181010133639_backfill_store_project_full_path_in_repo.rb index 247f5980f7e..c0d609d2cd4 100644 --- a/db/post_migrate/20181010133639_backfill_store_project_full_path_in_repo.rb +++ b/db/post_migrate/20181010133639_backfill_store_project_full_path_in_repo.rb @@ -6,13 +6,13 @@ class BackfillStoreProjectFullPathInRepo < ActiveRecord::Migration[4.2] DOWNTIME = false BATCH_SIZE = 1_000 DELAY_INTERVAL = 5.minutes - UP_MIGRATION = 'BackfillProjectFullpathInRepoConfig::Up' - DOWN_MIGRATION = 'BackfillProjectFullpathInRepoConfig::Down' + UP_MIGRATION = "BackfillProjectFullpathInRepoConfig::Up" + DOWN_MIGRATION = "BackfillProjectFullpathInRepoConfig::Down" disable_ddl_transaction! class Project < ActiveRecord::Base - self.table_name = 'projects' + self.table_name = "projects" include EachBatch end diff --git a/db/post_migrate/20181014121030_enqueue_redact_links.rb b/db/post_migrate/20181014121030_enqueue_redact_links.rb index 8d1a840d594..d87229083fd 100644 --- a/db/post_migrate/20181014121030_enqueue_redact_links.rb +++ b/db/post_migrate/20181014121030_enqueue_redact_links.rb @@ -6,44 +6,44 @@ class EnqueueRedactLinks < ActiveRecord::Migration[4.2] DOWNTIME = false BATCH_SIZE = 1000 DELAY_INTERVAL = 5.minutes.to_i - MIGRATION = 'RedactLinks' + MIGRATION = "RedactLinks" disable_ddl_transaction! class Note < ActiveRecord::Base include EachBatch - self.table_name = 'notes' + self.table_name = "notes" self.inheritance_column = :_type_disabled end class Issue < ActiveRecord::Base include EachBatch - self.table_name = 'issues' + self.table_name = "issues" self.inheritance_column = :_type_disabled end class MergeRequest < ActiveRecord::Base include EachBatch - self.table_name = 'merge_requests' + self.table_name = "merge_requests" self.inheritance_column = :_type_disabled end class Snippet < ActiveRecord::Base include EachBatch - self.table_name = 'snippets' + self.table_name = "snippets" self.inheritance_column = :_type_disabled end def up disable_statement_timeout do - schedule_migration(Note, 'note') - schedule_migration(Issue, 'description') - schedule_migration(MergeRequest, 'description') - schedule_migration(Snippet, 'description') + schedule_migration(Note, "note") + schedule_migration(Issue, "description") + schedule_migration(MergeRequest, "description") + schedule_migration(Snippet, "description") end end @@ -57,7 +57,7 @@ class EnqueueRedactLinks < ActiveRecord::Migration[4.2] link_pattern = "%/sent_notifications/" + ("_" * 32) + "/unsubscribe%" model.where("#{field} like ?", link_pattern).each_batch(of: BATCH_SIZE) do |batch, index| - start_id, stop_id = batch.pluck('MIN(id)', 'MAX(id)').first + start_id, stop_id = batch.pluck("MIN(id)", "MAX(id)").first BackgroundMigrationWorker.perform_in(index * DELAY_INTERVAL, MIGRATION, [model.name.demodulize, field, start_id, stop_id]) end diff --git a/db/post_migrate/20181022173835_enqueue_populate_cluster_kubernetes_namespace.rb b/db/post_migrate/20181022173835_enqueue_populate_cluster_kubernetes_namespace.rb index 94a4574abff..e1bb3e47efa 100644 --- a/db/post_migrate/20181022173835_enqueue_populate_cluster_kubernetes_namespace.rb +++ b/db/post_migrate/20181022173835_enqueue_populate_cluster_kubernetes_namespace.rb @@ -4,7 +4,7 @@ class EnqueuePopulateClusterKubernetesNamespace < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false - MIGRATION = 'PopulateClusterKubernetesNamespaceTable'.freeze + MIGRATION = "PopulateClusterKubernetesNamespaceTable" disable_ddl_transaction! diff --git a/db/post_migrate/20181026091631_migrate_forbidden_redirect_uris.rb b/db/post_migrate/20181026091631_migrate_forbidden_redirect_uris.rb index 7c2df832882..1f11dd42407 100644 --- a/db/post_migrate/20181026091631_migrate_forbidden_redirect_uris.rb +++ b/db/post_migrate/20181026091631_migrate_forbidden_redirect_uris.rb @@ -5,7 +5,7 @@ class MigrateForbiddenRedirectUris < ActiveRecord::Migration[4.2] DOWNTIME = false FORBIDDEN_SCHEMES = %w[data:// vbscript:// javascript://] - NEW_URI = 'http://forbidden-scheme-has-been-overwritten' + NEW_URI = "http://forbidden-scheme-has-been-overwritten" disable_ddl_transaction! @@ -22,9 +22,9 @@ class MigrateForbiddenRedirectUris < ActiveRecord::Migration[4.2] def update_forbidden_uris(table_name) update_column_in_batches(table_name, :redirect_uri, NEW_URI) do |table, query| - where_clause = FORBIDDEN_SCHEMES.map do |scheme| + where_clause = FORBIDDEN_SCHEMES.map { |scheme| table[:redirect_uri].matches("#{scheme}%") - end.inject(&:or) + }.inject(&:or) query.where(where_clause) end diff --git a/db/post_migrate/20181030135124_fill_empty_finished_at_in_deployments.rb b/db/post_migrate/20181030135124_fill_empty_finished_at_in_deployments.rb index 228841a14a0..c5a176033de 100644 --- a/db/post_migrate/20181030135124_fill_empty_finished_at_in_deployments.rb +++ b/db/post_migrate/20181030135124_fill_empty_finished_at_in_deployments.rb @@ -7,17 +7,17 @@ class FillEmptyFinishedAtInDeployments < ActiveRecord::Migration[4.2] DEPLOYMENT_STATUS_SUCCESS = 2 # Equivalent to Deployment.statuses[:success] class Deployments < ActiveRecord::Base - self.table_name = 'deployments' + self.table_name = "deployments" include EachBatch end def up FillEmptyFinishedAtInDeployments::Deployments - .where('finished_at IS NULL') - .where('status = ?', DEPLOYMENT_STATUS_SUCCESS) + .where("finished_at IS NULL") + .where("status = ?", DEPLOYMENT_STATUS_SUCCESS) .each_batch(of: 10_000) do |relation| - relation.update_all('finished_at=created_at') + relation.update_all("finished_at=created_at") end end diff --git a/db/post_migrate/20181101091005_steal_digest_column.rb b/db/post_migrate/20181101091005_steal_digest_column.rb index 58ea710c18a..acfadedffc7 100644 --- a/db/post_migrate/20181101091005_steal_digest_column.rb +++ b/db/post_migrate/20181101091005_steal_digest_column.rb @@ -8,7 +8,7 @@ class StealDigestColumn < ActiveRecord::Migration[5.0] disable_ddl_transaction! def up - Gitlab::BackgroundMigration.steal('DigestColumn') + Gitlab::BackgroundMigration.steal("DigestColumn") end def down diff --git a/db/post_migrate/20181105201455_steal_fill_store_upload.rb b/db/post_migrate/20181105201455_steal_fill_store_upload.rb index a31a4eab472..b823e8d047d 100644 --- a/db/post_migrate/20181105201455_steal_fill_store_upload.rb +++ b/db/post_migrate/20181105201455_steal_fill_store_upload.rb @@ -11,15 +11,15 @@ class StealFillStoreUpload < ActiveRecord::Migration[4.2] class Upload < ActiveRecord::Base include EachBatch - self.table_name = 'uploads' + self.table_name = "uploads" self.inheritance_column = :_type_disabled # Disable STI end def up - Gitlab::BackgroundMigration.steal('FillStoreUpload') + Gitlab::BackgroundMigration.steal("FillStoreUpload") Upload.where(store: nil).each_batch(of: BATCH_SIZE) do |batch| - range = batch.pluck('MIN(id)', 'MAX(id)').first + range = batch.pluck("MIN(id)", "MAX(id)").first Gitlab::BackgroundMigration::FillStoreUpload.new.perform(*range) end diff --git a/db/post_migrate/20181107054254_remove_restricted_todos_again.rb b/db/post_migrate/20181107054254_remove_restricted_todos_again.rb index bbeb4e8a1de..58bba0a8bca 100644 --- a/db/post_migrate/20181107054254_remove_restricted_todos_again.rb +++ b/db/post_migrate/20181107054254_remove_restricted_todos_again.rb @@ -7,20 +7,20 @@ class RemoveRestrictedTodosAgain < ActiveRecord::Migration[4.2] DOWNTIME = false disable_ddl_transaction! - MIGRATION = 'RemoveRestrictedTodos'.freeze + MIGRATION = "RemoveRestrictedTodos" BATCH_SIZE = 1000 DELAY_INTERVAL = 5.minutes.to_i class Project < ActiveRecord::Base include EachBatch - self.table_name = 'projects' + self.table_name = "projects" end def up - Project.where('EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)') + Project.where("EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)") .each_batch(of: BATCH_SIZE) do |batch, index| - range = batch.pluck('MIN(id)', 'MAX(id)').first + range = batch.pluck("MIN(id)", "MAX(id)").first BackgroundMigrationWorker.perform_in(index * DELAY_INTERVAL, MIGRATION, range) end diff --git a/db/post_migrate/20181121111200_schedule_runners_token_encryption.rb b/db/post_migrate/20181121111200_schedule_runners_token_encryption.rb index ba82072fc98..30f2a7b526c 100644 --- a/db/post_migrate/20181121111200_schedule_runners_token_encryption.rb +++ b/db/post_migrate/20181121111200_schedule_runners_token_encryption.rb @@ -6,13 +6,13 @@ class ScheduleRunnersTokenEncryption < ActiveRecord::Migration[4.2] DOWNTIME = false BATCH_SIZE = 10000 RANGE_SIZE = 2000 - MIGRATION = 'EncryptRunnersTokens' + MIGRATION = "EncryptRunnersTokens" MODELS = [ ::Gitlab::BackgroundMigration::Models::EncryptColumns::Settings, ::Gitlab::BackgroundMigration::Models::EncryptColumns::Namespace, ::Gitlab::BackgroundMigration::Models::EncryptColumns::Project, - ::Gitlab::BackgroundMigration::Models::EncryptColumns::Runner + ::Gitlab::BackgroundMigration::Models::EncryptColumns::Runner, ].freeze disable_ddl_transaction! @@ -23,7 +23,7 @@ class ScheduleRunnersTokenEncryption < ActiveRecord::Migration[4.2] delay = index * 4.minutes relation.each_batch(of: RANGE_SIZE) do |relation| - range = relation.pluck('MIN(id)', 'MAX(id)').first + range = relation.pluck("MIN(id)", "MAX(id)").first args = [model.name.demodulize.downcase, *range] BackgroundMigrationWorker.perform_in(delay, MIGRATION, args) diff --git a/db/post_migrate/20181123042307_drop_site_statistics.rb b/db/post_migrate/20181123042307_drop_site_statistics.rb index 8986374ef65..e200b5a509d 100644 --- a/db/post_migrate/20181123042307_drop_site_statistics.rb +++ b/db/post_migrate/20181123042307_drop_site_statistics.rb @@ -17,6 +17,6 @@ class DropSiteStatistics < ActiveRecord::Migration[5.0] t.integer :repositories_count, default: 0, null: false end - execute('INSERT INTO site_statistics (id) VALUES(1)') + execute("INSERT INTO site_statistics (id) VALUES(1)") end end diff --git a/db/post_migrate/20181130102132_backfill_hashed_project_repositories.rb b/db/post_migrate/20181130102132_backfill_hashed_project_repositories.rb index 7814cdba58a..df8a3bb10c7 100644 --- a/db/post_migrate/20181130102132_backfill_hashed_project_repositories.rb +++ b/db/post_migrate/20181130102132_backfill_hashed_project_repositories.rb @@ -6,14 +6,14 @@ class BackfillHashedProjectRepositories < ActiveRecord::Migration[4.2] DOWNTIME = false BATCH_SIZE = 1_000 DELAY_INTERVAL = 5.minutes - MIGRATION = 'BackfillHashedProjectRepositories' + MIGRATION = "BackfillHashedProjectRepositories" disable_ddl_transaction! class Project < ActiveRecord::Base include EachBatch - self.table_name = 'projects' + self.table_name = "projects" end def up diff --git a/db/post_migrate/20181204154019_populate_mr_metrics_with_events_data.rb b/db/post_migrate/20181204154019_populate_mr_metrics_with_events_data.rb index 1e43e3dd790..ccffe5d2463 100644 --- a/db/post_migrate/20181204154019_populate_mr_metrics_with_events_data.rb +++ b/db/post_migrate/20181204154019_populate_mr_metrics_with_events_data.rb @@ -8,8 +8,8 @@ class PopulateMrMetricsWithEventsData < ActiveRecord::Migration[4.2] DOWNTIME = false BATCH_SIZE = 10_000 - MIGRATION = 'PopulateMergeRequestMetricsWithEventsDataImproved' - PREVIOUS_MIGRATION = 'PopulateMergeRequestMetricsWithEventsData' + MIGRATION = "PopulateMergeRequestMetricsWithEventsDataImproved" + PREVIOUS_MIGRATION = "PopulateMergeRequestMetricsWithEventsData" disable_ddl_transaction! @@ -18,7 +18,7 @@ class PopulateMrMetricsWithEventsData < ActiveRecord::Migration[4.2] # previous try (see https://gitlab.com/gitlab-org/gitlab-ce/issues/47676). Gitlab::BackgroundMigration.steal(PREVIOUS_MIGRATION) - say 'Scheduling `PopulateMergeRequestMetricsWithEventsData` jobs' + say "Scheduling `PopulateMergeRequestMetricsWithEventsData` jobs" # It will update around 4_000_000 records in batches of 10_000 merge # requests (running between 5 minutes) and should take around 53 hours to complete. # Apparently, production PostgreSQL is able to vacuum 10k-20k dead_tuples @@ -27,7 +27,7 @@ class PopulateMrMetricsWithEventsData < ActiveRecord::Migration[4.2] # More information about the updates in `PopulateMergeRequestMetricsWithEventsDataImproved` class. # MergeRequest.all.each_batch(of: BATCH_SIZE) do |relation, index| - range = relation.pluck('MIN(id)', 'MAX(id)').first + range = relation.pluck("MIN(id)", "MAX(id)").first BackgroundMigrationWorker.perform_in(index * 8.minutes, MIGRATION, range) end diff --git a/db/post_migrate/20181219130552_update_project_import_visibility_level.rb b/db/post_migrate/20181219130552_update_project_import_visibility_level.rb index 6209de88b31..697df94d413 100644 --- a/db/post_migrate/20181219130552_update_project_import_visibility_level.rb +++ b/db/post_migrate/20181219130552_update_project_import_visibility_level.rb @@ -13,7 +13,7 @@ class UpdateProjectImportVisibilityLevel < ActiveRecord::Migration[5.0] disable_ddl_transaction! class Namespace < ActiveRecord::Base - self.table_name = 'namespaces' + self.table_name = "namespaces" end class Project < ActiveRecord::Base @@ -21,16 +21,16 @@ class UpdateProjectImportVisibilityLevel < ActiveRecord::Migration[5.0] belongs_to :namespace - IMPORT_TYPE = 'gitlab_project' + IMPORT_TYPE = "gitlab_project" scope :with_group_visibility, ->(visibility) do joins(:namespace) - .where(namespaces: { type: 'Group', visibility_level: visibility }) + .where(namespaces: {type: "Group", visibility_level: visibility}) .where(import_type: IMPORT_TYPE) - .where('projects.visibility_level > namespaces.visibility_level') + .where("projects.visibility_level > namespaces.visibility_level") end - self.table_name = 'projects' + self.table_name = "projects" end def up @@ -49,7 +49,7 @@ class UpdateProjectImportVisibilityLevel < ActiveRecord::Migration[5.0] def update_projects_visibility(visibility) say_with_time("Updating project visibility to #{visibility} on #{Project::IMPORT_TYPE} imports.") do Project.with_group_visibility(visibility).select(:id).each_batch(of: BATCH_SIZE) do |batch, _index| - batch_sql = Gitlab::Database.mysql? ? batch.pluck(:id).join(', ') : batch.select(:id).to_sql + batch_sql = Gitlab::Database.mysql? ? batch.pluck(:id).join(", ") : batch.select(:id).to_sql say("Updating #{batch.size} items.", true) diff --git a/db/post_migrate/20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb b/db/post_migrate/20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb index c37f8c039c0..fcaa60180e4 100644 --- a/db/post_migrate/20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb +++ b/db/post_migrate/20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb @@ -6,10 +6,10 @@ class MigrateClusterConfigureWorkerSidekiqQueue < ActiveRecord::Migration[5.0] DOWNTIME = false def up - sidekiq_queue_migrate 'gcp_cluster:cluster_platform_configure', to: 'gcp_cluster:cluster_configure' + sidekiq_queue_migrate "gcp_cluster:cluster_platform_configure", to: "gcp_cluster:cluster_configure" end def down - sidekiq_queue_migrate 'gcp_cluster:cluster_configure', to: 'gcp_cluster:cluster_platform_configure' + sidekiq_queue_migrate "gcp_cluster:cluster_configure", to: "gcp_cluster:cluster_platform_configure" end end diff --git a/db/post_migrate/20190102152410_delete_inconsistent_internal_id_records2.rb b/db/post_migrate/20190102152410_delete_inconsistent_internal_id_records2.rb index ddcddcf72a3..9de64674794 100644 --- a/db/post_migrate/20190102152410_delete_inconsistent_internal_id_records2.rb +++ b/db/post_migrate/20190102152410_delete_inconsistent_internal_id_records2.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class DeleteInconsistentInternalIdRecords2 < ActiveRecord::Migration[5.0] include Gitlab::Database::MigrationHelpers @@ -14,14 +15,14 @@ class DeleteInconsistentInternalIdRecords2 < ActiveRecord::Migration[5.0] def up disable_statement_timeout do - delete_internal_id_records('milestones', 'project_id') - delete_internal_id_records('milestones', 'namespace_id', 'group_id') + delete_internal_id_records("milestones", "project_id") + delete_internal_id_records("milestones", "namespace_id", "group_id") end end class InternalId < ActiveRecord::Base - self.table_name = 'internal_ids' - enum usage: { issues: 0, merge_requests: 1, deployments: 2, milestones: 3, epics: 4, ci_pipelines: 5 } + self.table_name = "internal_ids" + enum usage: {issues: 0, merge_requests: 1, deployments: 2, milestones: 3, epics: 4, ci_pipelines: 5} end private diff --git a/db/post_migrate/20190115054215_migrate_delete_container_repository_worker.rb b/db/post_migrate/20190115054215_migrate_delete_container_repository_worker.rb index 4fcee326b7e..487b91992f7 100644 --- a/db/post_migrate/20190115054215_migrate_delete_container_repository_worker.rb +++ b/db/post_migrate/20190115054215_migrate_delete_container_repository_worker.rb @@ -6,10 +6,10 @@ class MigrateDeleteContainerRepositoryWorker < ActiveRecord::Migration[5.0] DOWNTIME = false def up - sidekiq_queue_migrate('delete_container_repository', to: 'container_repository:delete_container_repository') + sidekiq_queue_migrate("delete_container_repository", to: "container_repository:delete_container_repository") end def down - sidekiq_queue_migrate('container_repository:delete_container_repository', to: 'delete_container_repository') + sidekiq_queue_migrate("container_repository:delete_container_repository", to: "delete_container_repository") end end diff --git a/db/post_migrate/20190124200344_migrate_storage_migrator_sidekiq_queue.rb b/db/post_migrate/20190124200344_migrate_storage_migrator_sidekiq_queue.rb index 193bd571831..72c7f06236c 100644 --- a/db/post_migrate/20190124200344_migrate_storage_migrator_sidekiq_queue.rb +++ b/db/post_migrate/20190124200344_migrate_storage_migrator_sidekiq_queue.rb @@ -9,10 +9,10 @@ class MigrateStorageMigratorSidekiqQueue < ActiveRecord::Migration[5.0] DOWNTIME = false def up - sidekiq_queue_migrate 'storage_migrator', to: 'hashed_storage:hashed_storage_migrator' + sidekiq_queue_migrate "storage_migrator", to: "hashed_storage:hashed_storage_migrator" end def down - sidekiq_queue_migrate 'hashed_storage:hashed_storage_migrator', to: 'storage_migrator' + sidekiq_queue_migrate "hashed_storage:hashed_storage_migrator", to: "storage_migrator" end end diff --git a/db/post_migrate/20190131122559_fix_null_type_labels.rb b/db/post_migrate/20190131122559_fix_null_type_labels.rb index 83bb613990c..c23b5e8b41b 100644 --- a/db/post_migrate/20190131122559_fix_null_type_labels.rb +++ b/db/post_migrate/20190131122559_fix_null_type_labels.rb @@ -8,7 +8,7 @@ class FixNullTypeLabels < ActiveRecord::Migration[5.0] disable_ddl_transaction! def up - update_column_in_batches(:labels, :type, 'ProjectLabel') do |table, query| + update_column_in_batches(:labels, :type, "ProjectLabel") do |table, query| query.where( table[:project_id].not_eq(nil) .and(table[:template].eq(false)) diff --git a/db/post_migrate/20190204115450_migrate_auto_dev_ops_domain_to_cluster_domain.rb b/db/post_migrate/20190204115450_migrate_auto_dev_ops_domain_to_cluster_domain.rb index 392e64eeade..78f8d3ea2b5 100644 --- a/db/post_migrate/20190204115450_migrate_auto_dev_ops_domain_to_cluster_domain.rb +++ b/db/post_migrate/20190204115450_migrate_auto_dev_ops_domain_to_cluster_domain.rb @@ -25,25 +25,25 @@ class MigrateAutoDevOpsDomainToClusterDomain < ActiveRecord::Migration[5.0] def mysql_query <<~HEREDOC - UPDATE clusters, project_auto_devops, cluster_projects - SET - clusters.domain = project_auto_devops.domain - WHERE - cluster_projects.cluster_id = clusters.id - AND project_auto_devops.project_id = cluster_projects.project_id - AND project_auto_devops.domain != '' + UPDATE clusters, project_auto_devops, cluster_projects + SET + clusters.domain = project_auto_devops.domain + WHERE + cluster_projects.cluster_id = clusters.id + AND project_auto_devops.project_id = cluster_projects.project_id + AND project_auto_devops.domain != '' HEREDOC end def postgresql_query <<~HEREDOC - UPDATE clusters - SET domain = project_auto_devops.domain - FROM cluster_projects, project_auto_devops - WHERE - cluster_projects.cluster_id = clusters.id - AND project_auto_devops.project_id = cluster_projects.project_id - AND project_auto_devops.domain != '' + UPDATE clusters + SET domain = project_auto_devops.domain + FROM cluster_projects, project_auto_devops + WHERE + cluster_projects.cluster_id = clusters.id + AND project_auto_devops.project_id = cluster_projects.project_id + AND project_auto_devops.domain != '' HEREDOC end end |