diff options
Diffstat (limited to 'db/migrate')
273 files changed, 826 insertions, 821 deletions
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 |