Commit 43971ef2 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Enable rubocop for db/**/* and ee/db/**/*

parent 73e0679e
...@@ -10,9 +10,9 @@ AllCops: ...@@ -10,9 +10,9 @@ AllCops:
Exclude: Exclude:
- 'vendor/**/*' - 'vendor/**/*'
- 'node_modules/**/*' - 'node_modules/**/*'
- 'db/**/*'
- 'db/fixtures/**/*' - 'db/fixtures/**/*'
- 'ee/db/**/*' - 'db/schema.rb'
- 'ee/db/geo/schema.rb'
- 'tmp/**/*' - 'tmp/**/*'
- 'bin/**/*' - 'bin/**/*'
- 'generator_templates/**/*' - 'generator_templates/**/*'
...@@ -34,6 +34,8 @@ Style/MutableConstant: ...@@ -34,6 +34,8 @@ Style/MutableConstant:
Naming/FileName: Naming/FileName:
ExpectMatchingDefinition: true ExpectMatchingDefinition: true
Exclude: Exclude:
- 'db/**/*'
- 'ee/db/**/*'
- 'spec/**/*' - 'spec/**/*'
- 'features/**/*' - 'features/**/*'
- 'ee/spec/**/*' - 'ee/spec/**/*'
......
class InitSchema < ActiveRecord::Migration class InitSchema < ActiveRecord::Migration
DOWNTIME = true DOWNTIME = true
# rubocop:disable Metrics/AbcSize
def up def up
create_table "broadcast_messages", force: :cascade do |t| create_table "broadcast_messages", force: :cascade do |t|
t.text "message", null: false t.text "message", null: false
...@@ -157,9 +158,9 @@ class InitSchema < ActiveRecord::Migration ...@@ -157,9 +158,9 @@ class InitSchema < ActiveRecord::Migration
add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree
add_index "notes", ["commit_id"], name: "index_notes_on_commit_id", using: :btree add_index "notes", ["commit_id"], name: "index_notes_on_commit_id", using: :btree
add_index "notes", ["created_at"], name: "index_notes_on_created_at", using: :btree add_index "notes", ["created_at"], name: "index_notes_on_created_at", using: :btree
add_index "notes", ["noteable_id", "noteable_type"], name: "index_notes_on_noteable_id_and_noteable_type", using: :btree add_index "notes", %w[noteable_id noteable_type], name: "index_notes_on_noteable_id_and_noteable_type", using: :btree
add_index "notes", ["noteable_type"], name: "index_notes_on_noteable_type", using: :btree add_index "notes", ["noteable_type"], name: "index_notes_on_noteable_type", using: :btree
add_index "notes", ["project_id", "noteable_type"], name: "index_notes_on_project_id_and_noteable_type", using: :btree add_index "notes", %w[project_id noteable_type], name: "index_notes_on_project_id_and_noteable_type", using: :btree
add_index "notes", ["project_id"], name: "index_notes_on_project_id", using: :btree add_index "notes", ["project_id"], name: "index_notes_on_project_id", using: :btree
create_table "project_group_links", force: :cascade do |t| create_table "project_group_links", force: :cascade do |t|
t.integer "project_id", null: false t.integer "project_id", null: false
...@@ -241,7 +242,7 @@ class InitSchema < ActiveRecord::Migration ...@@ -241,7 +242,7 @@ class InitSchema < ActiveRecord::Migration
t.datetime "created_at" t.datetime "created_at"
end end
add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id", using: :btree add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id", using: :btree
add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree add_index "taggings", %w[taggable_id taggable_type context], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree
create_table "tags", force: :cascade do |t| create_table "tags", force: :cascade do |t|
t.string "name" t.string "name"
end end
...@@ -292,7 +293,7 @@ class InitSchema < ActiveRecord::Migration ...@@ -292,7 +293,7 @@ class InitSchema < ActiveRecord::Migration
add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true, using: :btree add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true, using: :btree
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["extern_uid", "provider"], name: "index_users_on_extern_uid_and_provider", unique: true, using: :btree add_index "users", %w[extern_uid provider], name: "index_users_on_extern_uid_and_provider", unique: true, using: :btree
add_index "users", ["name"], name: "index_users_on_name", using: :btree add_index "users", ["name"], name: "index_users_on_name", using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
add_index "users", ["username"], name: "index_users_on_username", using: :btree add_index "users", ["username"], name: "index_users_on_username", using: :btree
......
# rubocop:disable all
class FixNamespaces < ActiveRecord::Migration class FixNamespaces < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
......
# rubocop:disable all
require_relative 'limits_to_mysql' require_relative 'limits_to_mysql'
# rubocop:disable all
class MigrateProjectTags < ActiveRecord::Migration class MigrateProjectTags < ActiveRecord::Migration
def up 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')
......
# rubocop:disable all
# In 20140914145549_migrate_to_new_members_model.rb we forgot to set the # In 20140914145549_migrate_to_new_members_model.rb we forgot to set the
# created_at and updated_at times for new records in the 'members' table. This # created_at and updated_at times for new records in the 'members' table. This
# became a problem after commit c8e78d972a5a628870eefca0f2ccea0199c55bda which # became a problem after commit c8e78d972a5a628870eefca0f2ccea0199c55bda which
......
# rubocop:disable all
class AddImportDataToProjectTable < ActiveRecord::Migration class AddImportDataToProjectTable < ActiveRecord::Migration
def change def change
add_column :projects, :import_type, :string add_column :projects, :import_type, :string
......
# rubocop:disable all
class AddHomePageUrlForApplicationSettings < ActiveRecord::Migration class AddHomePageUrlForApplicationSettings < ActiveRecord::Migration
def change def change
add_column :application_settings, :home_page_url, :string add_column :application_settings, :home_page_url, :string
......
# rubocop:disable all
class AddGitlabAccessTokenToUser < ActiveRecord::Migration class AddGitlabAccessTokenToUser < ActiveRecord::Migration
def change def change
add_column :users, :gitlab_access_token, :string add_column :users, :gitlab_access_token, :string
......
# rubocop:disable all
class AddNotificationEmailToUser < ActiveRecord::Migration class AddNotificationEmailToUser < ActiveRecord::Migration
def up def up
add_column :users, :notification_email, :string add_column :users, :notification_email, :string
......
# rubocop:disable all
class AllowNullInServicesProjectId < ActiveRecord::Migration class AllowNullInServicesProjectId < ActiveRecord::Migration
def change def change
change_column :services, :project_id, :integer, null: true change_column :services, :project_id, :integer, null: true
......
# rubocop:disable all
class AddBitbucketAccessTokenAndSecretToUser < ActiveRecord::Migration class AddBitbucketAccessTokenAndSecretToUser < ActiveRecord::Migration
def change def change
add_column :users, :bitbucket_access_token, :string add_column :users, :bitbucket_access_token, :string
......
# rubocop:disable all
class SetMissingLastActivityAt < ActiveRecord::Migration class SetMissingLastActivityAt < ActiveRecord::Migration
def up def up
execute "UPDATE projects SET last_activity_at = updated_at WHERE last_activity_at IS NULL" execute "UPDATE projects SET last_activity_at = updated_at WHERE last_activity_at IS NULL"
......
# rubocop:disable all
class AddRestrictedVisibilityLevelsToApplicationSettings < ActiveRecord::Migration class AddRestrictedVisibilityLevelsToApplicationSettings < ActiveRecord::Migration
def change def change
add_column :application_settings, :restricted_visibility_levels, :text add_column :application_settings, :restricted_visibility_levels, :text
......
# rubocop:disable all
class AddLocationToUser < ActiveRecord::Migration class AddLocationToUser < ActiveRecord::Migration
def change def change
add_column :users, :location, :string add_column :users, :location, :string
......
# rubocop:disable all
class SetIncorrectAssigneeIdToNull < ActiveRecord::Migration class SetIncorrectAssigneeIdToNull < ActiveRecord::Migration
def up def up
execute "UPDATE issues SET assignee_id = NULL WHERE assignee_id = -1" execute "UPDATE issues SET assignee_id = NULL WHERE assignee_id = -1"
......
# rubocop:disable all
class AddImportDataToProject < ActiveRecord::Migration class AddImportDataToProject < ActiveRecord::Migration
def change def change
add_column :projects, :import_data, :text add_column :projects, :import_data, :text
......
# rubocop:disable all
class AddDeviseTwoFactorToUsers < ActiveRecord::Migration class AddDeviseTwoFactorToUsers < ActiveRecord::Migration
def change def change
add_column :users, :encrypted_otp_secret, :string add_column :users, :encrypted_otp_secret, :string
......
# rubocop:disable all
class AddMaxAttachmentSizeToApplicationSettings < ActiveRecord::Migration class AddMaxAttachmentSizeToApplicationSettings < ActiveRecord::Migration
def change def change
add_column :application_settings, :max_attachment_size, :integer, default: 10, null: false add_column :application_settings, :max_attachment_size, :integer, default: 10, null: false
......
# rubocop:disable all
class AddDeviseTwoFactorBackupableToUsers < ActiveRecord::Migration class AddDeviseTwoFactorBackupableToUsers < ActiveRecord::Migration
def change def change
add_column :users, :otp_backup_codes, :text add_column :users, :otp_backup_codes, :text
......
# rubocop:disable all
class FixIdentities < ActiveRecord::Migration class FixIdentities < ActiveRecord::Migration
def up def up
# Up until now, legacy 'ldap' references in the database were charitably # Up until now, legacy 'ldap' references in the database were charitably
......
# rubocop:disable all
class RenameBuildboxService < ActiveRecord::Migration class RenameBuildboxService < ActiveRecord::Migration
def up def up
execute "UPDATE services SET type = 'BuildkiteService' WHERE type = 'BuildboxService';" execute "UPDATE services SET type = 'BuildkiteService' WHERE type = 'BuildboxService';"
......
# rubocop:disable all
class CreateProjectImportData < ActiveRecord::Migration class CreateProjectImportData < ActiveRecord::Migration
def change def change
create_table :project_import_data do |t| create_table :project_import_data do |t|
......
# rubocop:disable all
class AddDefaultProjectVisibililtyToApplicationSettings < ActiveRecord::Migration class AddDefaultProjectVisibililtyToApplicationSettings < ActiveRecord::Migration
def up def up
add_column :application_settings, :default_project_visibility, :integer add_column :application_settings, :default_project_visibility, :integer
......
# rubocop:disable all
# This migration is a duplicate of 20150425164651_change_collation_for_tag_names.acts_as_taggable_on_engine.rb # This migration is a duplicate of 20150425164651_change_collation_for_tag_names.acts_as_taggable_on_engine.rb
# It shold be applied before the index additions to ensure that `name` is case sensitive. # It shold be applied before the index additions to ensure that `name` is case sensitive.
......
# rubocop:disable all
# This migration comes from acts_as_taggable_on_engine (originally 4) # This migration comes from acts_as_taggable_on_engine (originally 4)
class AddMissingTaggableIndex < ActiveRecord::Migration class AddMissingTaggableIndex < ActiveRecord::Migration
def self.up def self.up
......
# rubocop:disable all
# This migration comes from acts_as_taggable_on_engine (originally 5) # This migration comes from acts_as_taggable_on_engine (originally 5)
# This migration is added to circumvent issue #623 and have special characters # This migration is added to circumvent issue #623 and have special characters
# work properly # work properly
......
# rubocop:disable all
class AddDefaultSnippetVisibilityToAppSettings < ActiveRecord::Migration class AddDefaultSnippetVisibilityToAppSettings < ActiveRecord::Migration
def up def up
add_column :application_settings, :default_snippet_visibility, :integer add_column :application_settings, :default_snippet_visibility, :integer
......
# rubocop:disable all
class RemoveAbandonedGroupMembersRecords < ActiveRecord::Migration class RemoveAbandonedGroupMembersRecords < ActiveRecord::Migration
def up def up
execute("DELETE FROM members WHERE type = 'GroupMember' AND source_id NOT IN(\ execute("DELETE FROM members WHERE type = 'GroupMember' AND source_id NOT IN(\
......
# rubocop:disable all
class AddRestrictedSignupDomainsToApplicationSettings < ActiveRecord::Migration class AddRestrictedSignupDomainsToApplicationSettings < ActiveRecord::Migration
def change def change
add_column :application_settings, :restricted_signup_domains, :text add_column :application_settings, :restricted_signup_domains, :text
......
# rubocop:disable all
# Convert legacy Markdown-emphasized notes to the current, non-emphasized format # Convert legacy Markdown-emphasized notes to the current, non-emphasized format
# #
# _mentioned in 54f7727c850972f0401c1312a7c4a6a380de5666_ # _mentioned in 54f7727c850972f0401c1312a7c4a6a380de5666_
......
# rubocop:disable all
class AddUserOauthApplicationsToApplicationSettings < ActiveRecord::Migration class AddUserOauthApplicationsToApplicationSettings < ActiveRecord::Migration
def change def change
add_column :application_settings, :user_oauth_applications, :bool, default: true add_column :application_settings, :user_oauth_applications, :bool, default: true
......
# rubocop:disable all
class AddSessionExpireDelayForApplicationSettings < ActiveRecord::Migration class AddSessionExpireDelayForApplicationSettings < ActiveRecord::Migration
def change def change
unless column_exists?(:application_settings, :session_expire_delay) unless column_exists?(:application_settings, :session_expire_delay)
......
# rubocop:disable all
class AddDefaultOtpRequiredForLoginValue < ActiveRecord::Migration class AddDefaultOtpRequiredForLoginValue < ActiveRecord::Migration
def up def up
execute %q{UPDATE users SET otp_required_for_login = FALSE WHERE otp_required_for_login IS NULL} execute %q{UPDATE users SET otp_required_for_login = FALSE WHERE otp_required_for_login IS NULL}
......
# rubocop:disable all
class AddUpdatedByToIssuablesAndNotes < ActiveRecord::Migration class AddUpdatedByToIssuablesAndNotes < ActiveRecord::Migration
def change def change
add_column :notes, :updated_by_id, :integer add_column :notes, :updated_by_id, :integer
......
# rubocop:disable all
class AddSentNotifications < ActiveRecord::Migration class AddSentNotifications < ActiveRecord::Migration
def change def change
create_table :sent_notifications do |t| create_table :sent_notifications do |t|
......
# rubocop:disable all
class EnableSslVerificationByDefault < ActiveRecord::Migration class EnableSslVerificationByDefault < ActiveRecord::Migration
def change def change
change_column :web_hooks, :enable_ssl_verification, :boolean, default: true change_column :web_hooks, :enable_ssl_verification, :boolean, default: true
......
# rubocop:disable all
class EnableSslVerificationForWebHooks < ActiveRecord::Migration class EnableSslVerificationForWebHooks < ActiveRecord::Migration
def up def up
execute("UPDATE web_hooks SET enable_ssl_verification = true") execute("UPDATE web_hooks SET enable_ssl_verification = true")
......
# rubocop:disable all
class AddHelpPageTextToApplicationSettings < ActiveRecord::Migration class AddHelpPageTextToApplicationSettings < ActiveRecord::Migration
def change def change
add_column :application_settings, :help_page_text, :text add_column :application_settings, :help_page_text, :text
......
# rubocop:disable all
class AddCiEnabledToApplicationSettings < ActiveRecord::Migration class AddCiEnabledToApplicationSettings < ActiveRecord::Migration
def change def change
add_column :application_settings, :ci_enabled, :boolean, null: false, default: true add_column :application_settings, :ci_enabled, :boolean, null: false, default: true
......
# rubocop:disable all
class RemoveInvalidMilestonesFromMergeRequests < ActiveRecord::Migration class RemoveInvalidMilestonesFromMergeRequests < ActiveRecord::Migration
def up def up
execute("UPDATE merge_requests SET milestone_id = NULL where milestone_id NOT IN (SELECT id FROM milestones)") execute("UPDATE merge_requests SET milestone_id = NULL where milestone_id NOT IN (SELECT id FROM milestones)")
......
# rubocop:disable all
class AddConsumedTimestepToUsers < ActiveRecord::Migration class AddConsumedTimestepToUsers < ActiveRecord::Migration
def change def change
add_column :users, :consumed_timestep, :integer add_column :users, :consumed_timestep, :integer
......
# rubocop:disable all
class AddLineCodeToSentNotification < ActiveRecord::Migration class AddLineCodeToSentNotification < ActiveRecord::Migration
def change def change
add_column :sent_notifications, :line_code, :string add_column :sent_notifications, :line_code, :string
......
# rubocop:disable all
class AddProjectIdToCiCommit < ActiveRecord::Migration class AddProjectIdToCiCommit < ActiveRecord::Migration
def up def up
add_column :ci_commits, :gl_project_id, :integer add_column :ci_commits, :gl_project_id, :integer
......
# rubocop:disable all
class MigrateProjectIdForCiCommits < ActiveRecord::Migration class MigrateProjectIdForCiCommits < ActiveRecord::Migration
def up 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'
......
# rubocop:disable all
class MergeRequestErrorField < ActiveRecord::Migration class MergeRequestErrorField < ActiveRecord::Migration
def up def up
add_column :merge_requests, :merge_error, :string add_column :merge_requests, :merge_error, :string
......
# rubocop:disable all
class AddNullToNameForCiProjects < ActiveRecord::Migration class AddNullToNameForCiProjects < ActiveRecord::Migration
def up def up
change_column_null :ci_projects, :name, true change_column_null :ci_projects, :name, true
......
# rubocop:disable all
class AddStageIdxToBuilds < ActiveRecord::Migration class AddStageIdxToBuilds < ActiveRecord::Migration
def change def change
add_column :ci_builds, :stage_idx, :integer add_column :ci_builds, :stage_idx, :integer
......
# rubocop:disable all
class AddRefAndTagToBuilds < ActiveRecord::Migration class AddRefAndTagToBuilds < ActiveRecord::Migration
def change def change
add_column :ci_builds, :tag, :boolean add_column :ci_builds, :tag, :boolean
......
# rubocop:disable all
class AddUserIdToBuild < ActiveRecord::Migration class AddUserIdToBuild < ActiveRecord::Migration
def change def change
add_column :ci_builds, :user_id, :integer add_column :ci_builds, :user_id, :integer
......
# rubocop:disable all
class AddAdminNotificationEmailSetting < ActiveRecord::Migration class AddAdminNotificationEmailSetting < ActiveRecord::Migration
def change def change
add_column :application_settings, :admin_notification_email, :string add_column :application_settings, :admin_notification_email, :string
......
# rubocop:disable all
class AddArtifactsFileToBuilds < ActiveRecord::Migration class AddArtifactsFileToBuilds < ActiveRecord::Migration
def change def change
add_column :ci_builds, :artifacts_file, :text add_column :ci_builds, :artifacts_file, :text
......
# rubocop:disable all
class FixBuildTags < ActiveRecord::Migration class FixBuildTags < ActiveRecord::Migration
def up def up
execute("UPDATE taggings SET taggable_type='CommitStatus' WHERE taggable_type='Ci::Build'") execute("UPDATE taggings SET taggable_type='CommitStatus' WHERE taggable_type='Ci::Build'")
......
# rubocop:disable all
class FailBuildWithoutNames < ActiveRecord::Migration class FailBuildWithoutNames < ActiveRecord::Migration
def up def up
execute("UPDATE ci_builds SET status='failed' WHERE name IS NULL AND status='pending'") execute("UPDATE ci_builds SET status='failed' WHERE name IS NULL AND status='pending'")
......
# rubocop:disable all
class CiLimitsToMysql < ActiveRecord::Migration class CiLimitsToMysql < ActiveRecord::Migration
def change def change
return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/ return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/
......
# rubocop:disable all
class FailBuildWithEmptyName < ActiveRecord::Migration class FailBuildWithEmptyName < ActiveRecord::Migration
def up def up
execute("UPDATE ci_builds SET status='failed' WHERE (name IS NULL OR name='') AND status='pending'") execute("UPDATE ci_builds SET status='failed' WHERE (name IS NULL OR name='') AND status='pending'")
......
# rubocop:disable all
require 'fileutils' require 'fileutils'
class RemoveSatellites < ActiveRecord::Migration class RemoveSatellites < ActiveRecord::Migration
......
# rubocop:disable all
class AddSharedRunnersSetting < ActiveRecord::Migration class AddSharedRunnersSetting < ActiveRecord::Migration
def up def up
add_column :application_settings, :shared_runners_enabled, :boolean, default: true, null: false add_column :application_settings, :shared_runners_enabled, :boolean, default: true, null: false
......
# rubocop:disable all
class AddFileToLfsObjects < ActiveRecord::Migration class AddFileToLfsObjects < ActiveRecord::Migration
def change def change
add_column :lfs_objects, :file, :string add_column :lfs_objects, :file, :string
......
# rubocop:disable all
class AddMaxArtifactsSizeToApplicationSettings < ActiveRecord::Migration class AddMaxArtifactsSizeToApplicationSettings < ActiveRecord::Migration
def change def change
add_column :application_settings, :max_artifacts_size, :integer, default: 100, null: false add_column :application_settings, :max_artifacts_size, :integer, default: 100, null: false
......
# rubocop:disable all
class AddImportErrorToProject < ActiveRecord::Migration class AddImportErrorToProject < ActiveRecord::Migration
def change def change
add_column :projects, :import_error, :text add_column :projects, :import_error, :text
......
# rubocop:disable all
class RaiseHookUrlLimit < ActiveRecord::Migration class RaiseHookUrlLimit < ActiveRecord::Migration
def change def change
change_column :web_hooks, :url, :string, limit: 2000 change_column :web_hooks, :url, :string, limit: 2000
......
# rubocop:disable all
class MigrateCiWebHooks < ActiveRecord::Migration class MigrateCiWebHooks < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable all
class MigrateCiEmails < ActiveRecord::Migration class MigrateCiEmails < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable all
class AddUnlockTokenToUser < ActiveRecord::Migration class AddUnlockTokenToUser < ActiveRecord::Migration
def change def change
add_column :users, :unlock_token, :string add_column :users, :unlock_token, :string
......
# rubocop:disable all
class AddRunnersRegistrationTokenToApplicationSettings < ActiveRecord::Migration class AddRunnersRegistrationTokenToApplicationSettings < ActiveRecord::Migration
def change def change
add_column :application_settings, :runners_registration_token, :string add_column :application_settings, :runners_registration_token, :string
......
# rubocop:disable all
class MigrateCiSlackService < ActiveRecord::Migration class MigrateCiSlackService < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable all
class MigrateCiHipChatService < ActiveRecord::Migration class MigrateCiHipChatService < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable all
class AddProjectIdToCi < ActiveRecord::Migration class AddProjectIdToCi < ActiveRecord::Migration
def change def change
add_column :ci_builds, :gl_project_id, :integer add_column :ci_builds, :gl_project_id, :integer
......
# rubocop:disable all
class MigrateCiToProject < ActiveRecord::Migration class MigrateCiToProject < ActiveRecord::Migration
def up def up
migrate_project_id_for_table('ci_runner_projects') migrate_project_id_for_table('ci_runner_projects')
......
# rubocop:disable all
class AddTfaToApplicationSettings < ActiveRecord::Migration class AddTfaToApplicationSettings < ActiveRecord::Migration
def change def change
change_table :application_settings do |t| change_table :application_settings do |t|
......
# rubocop:disable all
class AddTfaAdditionalFields < ActiveRecord::Migration class AddTfaAdditionalFields < ActiveRecord::Migration
def change def change
change_table :users do |t| change_table :users do |t|
......
# rubocop:disable all
# Migration type: online without errors (works on previous version and new one) # Migration type: online without errors (works on previous version and new one)
class RenameEmojis < ActiveRecord::Migration class RenameEmojis < ActiveRecord::Migration
def up def up
......
# rubocop:disable all
class AddRecaptchaToApplicationSettings < ActiveRecord::Migration class AddRecaptchaToApplicationSettings < ActiveRecord::Migration
def change def change
change_table :application_settings do |t| change_table :application_settings do |t|
......
# rubocop:disable all
class InfluxdbUdpPortSetting < ActiveRecord::Migration class InfluxdbUdpPortSetting < ActiveRecord::Migration
def change def change
add_column :application_settings, :metrics_port, :integer, default: 8089 add_column :application_settings, :metrics_port, :integer, default: 8089
......
# rubocop:disable all
class AddArtifactsMetadataToCiBuild < ActiveRecord::Migration class AddArtifactsMetadataToCiBuild < ActiveRecord::Migration
def change def change
add_column :ci_builds, :artifacts_metadata, :text add_column :ci_builds, :artifacts_metadata, :text
......
# rubocop:disable all
class AddAkismetToApplicationSettings < ActiveRecord::Migration class AddAkismetToApplicationSettings < ActiveRecord::Migration
def change def change
change_table :application_settings do |t| change_table :application_settings do |t|
......
# rubocop:disable all
class AddMetricsSampleInterval < ActiveRecord::Migration class AddMetricsSampleInterval < ActiveRecord::Migration
def change def change
add_column :application_settings, :metrics_sample_interval, :integer, add_column :application_settings, :metrics_sample_interval, :integer,
......
# rubocop:disable all
class AddSentryToApplicationSettings < ActiveRecord::Migration class AddSentryToApplicationSettings < ActiveRecord::Migration
def change def change
change_table :application_settings do |t| change_table :application_settings do |t|
......
# rubocop:disable all
class AddBaseCommitShaToMergeRequestDiffs < ActiveRecord::Migration class AddBaseCommitShaToMergeRequestDiffs < ActiveRecord::Migration
def change def change
add_column :merge_request_diffs, :base_commit_sha, :string add_column :merge_request_diffs, :base_commit_sha, :string
......
# rubocop:disable all
class ChangeLfsObjectsSizeColumn < ActiveRecord::Migration class ChangeLfsObjectsSizeColumn < ActiveRecord::Migration
def change def change
change_column :lfs_objects, :size, :integer, limit: 8 change_column :lfs_objects, :size, :integer, limit: 8
......
# rubocop:disable all
class RemoveDotAtomPathEndingOfProjects < ActiveRecord::Migration class RemoveDotAtomPathEndingOfProjects < ActiveRecord::Migration
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
......
# rubocop:disable all
class AddMergeCommitShaToMergeRequests < ActiveRecord::Migration class AddMergeCommitShaToMergeRequests < ActiveRecord::Migration
def change def change
add_column :merge_requests, :merge_commit_sha, :string add_column :merge_requests, :merge_commit_sha, :string
......
# rubocop:disable all
class AddRealSizeToMergeRequestDiffs < ActiveRecord::Migration class AddRealSizeToMergeRequestDiffs < ActiveRecord::Migration
def change def change
add_column :merge_request_diffs, :real_size, :string add_column :merge_request_diffs, :real_size, :string
......
# rubocop:disable all
class AddDescriptionToLabel < ActiveRecord::Migration class AddDescriptionToLabel < ActiveRecord::Migration
def change def change
add_column :labels, :description, :string add_column :labels, :description, :string
......
# rubocop:disable all
class AddNoteToTasks < ActiveRecord::Migration class AddNoteToTasks < ActiveRecord::Migration
def change def change
add_reference :tasks, :note, index: true add_reference :tasks, :note, index: true
......
# rubocop:disable all
class RenameTasksToTodos < ActiveRecord::Migration class RenameTasksToTodos < ActiveRecord::Migration
def change def change
rename_table :tasks, :todos rename_table :tasks, :todos
......
# rubocop:disable all
class AddMainLanguageToRepository < ActiveRecord::Migration class AddMainLanguageToRepository < ActiveRecord::Migration
def change def change
add_column :projects, :main_language, :string add_column :projects, :main_language, :string
......
# rubocop:disable all
class AddImportCredentialsToProjectImportData < ActiveRecord::Migration class AddImportCredentialsToProjectImportData < ActiveRecord::Migration
def change def change
add_column :project_import_data, :encrypted_credentials, :text add_column :project_import_data, :encrypted_credentials, :text
......
# rubocop:disable all
class DisallowBlankLineCodeOnNote < ActiveRecord::Migration class DisallowBlankLineCodeOnNote < ActiveRecord::Migration
def up def up
execute("UPDATE notes SET line_code = NULL WHERE line_code = ''") execute("UPDATE notes SET line_code = NULL WHERE line_code = ''")
......
# rubocop:disable all
class ChangeTargetIdToNullOnTodos < ActiveRecord::Migration class ChangeTargetIdToNullOnTodos < ActiveRecord::Migration
def change def change
change_column_null :todos, :target_id, true change_column_null :todos, :target_id, true
......
# rubocop:disable all
class AddMovedToToIssue < ActiveRecord::Migration class AddMovedToToIssue < ActiveRecord::Migration
def change def change
add_reference :issues, :moved_to, references: :issues add_reference :issues, :moved_to, references: :issues
......
# rubocop:disable all
class RemoveTodosForDeletedIssues < ActiveRecord::Migration class RemoveTodosForDeletedIssues < ActiveRecord::Migration
def up def up
execute <<-SQL execute <<-SQL
......
# rubocop:disable all
# This migration will create one row of NotificationSetting for each Member row # This migration will create one row of NotificationSetting for each Member row
# It can take long time on big instances. # It can take long time on big instances.
# #
......
# rubocop:disable all
class RemoveTodosForDeletedMergeRequests < ActiveRecord::Migration class RemoveTodosForDeletedMergeRequests < ActiveRecord::Migration
def up def up
execute <<-SQL execute <<-SQL
......
# rubocop:disable all
class AddImagesEnabledForProject < ActiveRecord::Migration class AddImagesEnabledForProject < ActiveRecord::Migration
def change def change
add_column :projects, :container_registry_enabled, :boolean add_column :projects, :container_registry_enabled, :boolean
......
# rubocop:disable all
class AddTokenToWebHooks < ActiveRecord::Migration class AddTokenToWebHooks < ActiveRecord::Migration
def change def change
add_column :web_hooks, :token, :string add_column :web_hooks, :token, :string
......
# rubocop:disable Migration/Datetime
# rubocop:disable Migration/Timestamps # rubocop:disable Migration/Timestamps
class CreatePersonalAccessTokens < ActiveRecord::Migration class CreatePersonalAccessTokens < ActiveRecord::Migration
def change def change
......
# rubocop:disable all
class AddSharedRunnersTextToApplicationSettings < ActiveRecord::Migration class AddSharedRunnersTextToApplicationSettings < ActiveRecord::Migration
def change def change
add_column :application_settings, :shared_runners_text, :text add_column :application_settings, :shared_runners_text, :text
......
# rubocop:disable all
class ConvertAwardNoteToEmojiAward < ActiveRecord::Migration class ConvertAwardNoteToEmojiAward < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
......
# rubocop:disable all
class AddMetricsPacketSize < ActiveRecord::Migration class AddMetricsPacketSize < ActiveRecord::Migration
def change def change
add_column :application_settings, :metrics_packet_size, :integer, default: 1 add_column :application_settings, :metrics_packet_size, :integer, default: 1
......
# rubocop:disable all
class AddDisabledOauthSignInSourcesToApplicationSettings < ActiveRecord::Migration class AddDisabledOauthSignInSourcesToApplicationSettings < ActiveRecord::Migration
def change def change
add_column :application_settings, :disabled_oauth_sign_in_sources, :text add_column :application_settings, :disabled_oauth_sign_in_sources, :text
......
# rubocop:disable all
class AddRunUntaggedToCiRunner < ActiveRecord::Migration class AddRunUntaggedToCiRunner < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
disable_ddl_transaction! disable_ddl_transaction!
......
# rubocop:disable all
class AddTypeToNotes < ActiveRecord::Migration class AddTypeToNotes < ActiveRecord::Migration
def change def change
add_column :notes, :type, :string add_column :notes, :type, :string
......
# rubocop:disable all
class AddHealthCheckAccessTokenToApplicationSettings < ActiveRecord::Migration class AddHealthCheckAccessTokenToApplicationSettings < ActiveRecord::Migration
def change def change
add_column :application_settings, :health_check_access_token, :string add_column :application_settings, :health_check_access_token, :string
......
# rubocop:disable all
class RemoveNotificationSettingsForDeletedProjects < ActiveRecord::Migration class RemoveNotificationSettingsForDeletedProjects < ActiveRecord::Migration
def up def up
execute <<-SQL execute <<-SQL
......
# rubocop:disable all
# This is ONLINE migration # This is ONLINE migration
class AddContainerRegistryTokenExpireDelayToApplicationSettings < ActiveRecord::Migration class AddContainerRegistryTokenExpireDelayToApplicationSettings < ActiveRecord::Migration
......
# rubocop:disable all
class RemoveDuplicatedNotificationSettings < ActiveRecord::Migration class RemoveDuplicatedNotificationSettings < ActiveRecord::Migration
def up def up
duplicates = exec_query(%Q{ duplicates = exec_query(%Q{
......
# rubocop:disable all
class AddAfterSignUpTextToApplicationSettings < ActiveRecord::Migration class AddAfterSignUpTextToApplicationSettings < ActiveRecord::Migration
def change def change
add_column :application_settings, :after_sign_up_text, :text add_column :application_settings, :after_sign_up_text, :text
......
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
# rubocop:disable Migration/Datetime
class AddDeployments < ActiveRecord::Migration class AddDeployments < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
# rubocop:disable Migration/Datetime
class AddEnvironments < ActiveRecord::Migration class AddEnvironments < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
# rubocop:disable all
class AddEnabledGitAccessProtocolsToApplicationSettings < ActiveRecord::Migration class AddEnabledGitAccessProtocolsToApplicationSettings < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable all
class RemoveDuplicatedKeys < ActiveRecord::Migration class RemoveDuplicatedKeys < ActiveRecord::Migration
def up def up
select_all("SELECT fingerprint FROM #{quote_table_name(:keys)} GROUP BY fingerprint HAVING COUNT(*) > 1").each do |row| select_all("SELECT fingerprint FROM #{quote_table_name(:keys)} GROUP BY fingerprint HAVING COUNT(*) > 1").each do |row|
......
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
# rubocop:disable Migration/Datetime
# rubocop:disable Migration/Timestamps # rubocop:disable Migration/Timestamps
class AddTableIssueMetrics < ActiveRecord::Migration class AddTableIssueMetrics < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
# rubocop:disable Migration/Datetime
# rubocop:disable Migration/Timestamps # rubocop:disable Migration/Timestamps
class AddTableMergeRequestMetrics < ActiveRecord::Migration class AddTableMergeRequestMetrics < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable Migration/Datetime
# rubocop:disable Migration/Timestamps # rubocop:disable Migration/Timestamps
class CreateUserChatNamesTable < ActiveRecord::Migration class CreateUserChatNamesTable < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable Migration/Datetime
class CreateUploads < ActiveRecord::Migration class CreateUploads < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable Migration/Datetime
class DropCiProjects < ActiveRecord::Migration class DropCiProjects < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable Migration/RemoveColumn # rubocop:disable Migration/RemoveColumn
# rubocop:disable Migration/Datetime
class RemoveUnusedCiTablesAndColumns < ActiveRecord::Migration class RemoveUnusedCiTablesAndColumns < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable Migration/Datetime
class CreateCiTriggerSchedules < ActiveRecord::Migration class CreateCiTriggerSchedules < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
# rubocop:disable RemoveIndex
class RemoveIndexForUsersCurrentSignInAt < ActiveRecord::Migration class RemoveIndexForUsersCurrentSignInAt < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable Migration/Datetime
# rubocop:disable Migration/Timestamps # rubocop:disable Migration/Timestamps
class CreatePipelineSchedulesTable < ActiveRecord::Migration class CreatePipelineSchedulesTable < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable all
require_relative 'markdown_cache_limits_to_mysql' require_relative 'markdown_cache_limits_to_mysql'
...@@ -6,6 +6,7 @@ class RenameUsersLdapEmailToExternalEmail < ActiveRecord::Migration ...@@ -6,6 +6,7 @@ class RenameUsersLdapEmailToExternalEmail < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
def up def up
# rubocop:disable Migration/UpdateLargeTable
rename_column_concurrently :users, :ldap_email, :external_email rename_column_concurrently :users, :ldap_email, :external_email
end end
......
...@@ -10,6 +10,7 @@ class AddTimezoneToIssuesClosedAt < ActiveRecord::Migration ...@@ -10,6 +10,7 @@ class AddTimezoneToIssuesClosedAt < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
def up def up
# rubocop:disable Migration/UpdateLargeTable
change_column_type_concurrently(:issues, :closed_at, :datetime_with_timezone) change_column_type_concurrently(:issues, :closed_at, :datetime_with_timezone)
end end
......
...@@ -25,6 +25,7 @@ class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration ...@@ -25,6 +25,7 @@ class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration
# Due to some EE merge problems some environments may not have the # Due to some EE merge problems some environments may not have the
# "closed_at_for_type_change" column. If this is the case we have no # "closed_at_for_type_change" column. If this is the case we have no
# other option than to migrate the data _right now_. # other option than to migrate the data _right now_.
# rubocop:disable Migration/UpdateLargeTable
change_column_type_concurrently(:issues, :closed_at, :datetime_with_timezone) change_column_type_concurrently(:issues, :closed_at, :datetime_with_timezone)
cleanup_concurrent_column_type_change(:issues, :closed_at) cleanup_concurrent_column_type_change(:issues, :closed_at)
end end
......
...@@ -12,6 +12,7 @@ class CreateBadges < ActiveRecord::Migration ...@@ -12,6 +12,7 @@ class CreateBadges < ActiveRecord::Migration
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
end end
# rubocop:disable Migration/AddConcurrentForeignKey
add_foreign_key :badges, :namespaces, column: :group_id, on_delete: :cascade add_foreign_key :badges, :namespaces, column: :group_id, on_delete: :cascade
end end
end end
...@@ -8,6 +8,7 @@ class AddGroupIdToBoardsCe < ActiveRecord::Migration ...@@ -8,6 +8,7 @@ class AddGroupIdToBoardsCe < ActiveRecord::Migration
def up def up
return if group_id_exists? return if group_id_exists?
# rubocop:disable Migration/AddConcurrentForeignKey
add_column :boards, :group_id, :integer add_column :boards, :group_id, :integer
add_foreign_key :boards, :namespaces, column: :group_id, on_delete: :cascade add_foreign_key :boards, :namespaces, column: :group_id, on_delete: :cascade
add_concurrent_index :boards, :group_id add_concurrent_index :boards, :group_id
...@@ -18,6 +19,7 @@ class AddGroupIdToBoardsCe < ActiveRecord::Migration ...@@ -18,6 +19,7 @@ class AddGroupIdToBoardsCe < ActiveRecord::Migration
def down def down
return unless group_id_exists? return unless group_id_exists?
# rubocop:disable Migration/RemoveIndex
remove_foreign_key :boards, column: :group_id remove_foreign_key :boards, column: :group_id
remove_index :boards, :group_id if index_exists? :boards, :group_id remove_index :boards, :group_id if index_exists? :boards, :group_id
remove_column :boards, :group_id remove_column :boards, :group_id
......
...@@ -8,6 +8,7 @@ class EnsureForeignKeysOnClustersApplications < ActiveRecord::Migration ...@@ -8,6 +8,7 @@ class EnsureForeignKeysOnClustersApplications < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
# rubocop:disable Cop/InBatches
def up def up
existing = Clusters::Cluster existing = Clusters::Cluster
.joins(:application_ingress) .joins(:application_ingress)
......
...@@ -7,15 +7,16 @@ class AddPartialIndexesOnTodos < ActiveRecord::Migration ...@@ -7,15 +7,16 @@ class AddPartialIndexesOnTodos < ActiveRecord::Migration
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
disable_ddl_transaction! disable_ddl_transaction!
INDEX_NAME_PENDING = "index_todos_on_user_id_and_id_pending"
INDEX_NAME_DONE = "index_todos_on_user_id_and_id_done"
INDEX_NAME_PENDING="index_todos_on_user_id_and_id_pending"
INDEX_NAME_DONE="index_todos_on_user_id_and_id_done"
def up def up
unless index_exists?(:todos, [:user_id, :id], name: INDEX_NAME_PENDING) unless index_exists?(:todos, [:user_id, :id], name: INDEX_NAME_PENDING)
add_concurrent_index(:todos, [:user_id, :id], where: "state='pending'", name: INDEX_NAME_PENDING) add_concurrent_index(:todos, [:user_id, :id], where: "state='pending'", name: INDEX_NAME_PENDING)
end end
unless index_exists?(:todos, [:user_id, :id], name: INDEX_NAME_DONE) unless index_exists?(:todos, [:user_id, :id], name: INDEX_NAME_DONE)
add_concurrent_index(:todos, [:user_id, :id], where: "state='done'", name: INDEX_NAME_DONE) add_concurrent_index(:todos, [:user_id, :id], where: "state='done'", name: INDEX_NAME_DONE)
end end
...@@ -24,5 +25,5 @@ class AddPartialIndexesOnTodos < ActiveRecord::Migration ...@@ -24,5 +25,5 @@ class AddPartialIndexesOnTodos < ActiveRecord::Migration
def down def down
remove_concurrent_index(:todos, [:user_id, :id], where: "state='pending'", name: INDEX_NAME_PENDING) remove_concurrent_index(:todos, [:user_id, :id], where: "state='pending'", name: INDEX_NAME_PENDING)
remove_concurrent_index(:todos, [:user_id, :id], where: "state='done'", name: INDEX_NAME_DONE) remove_concurrent_index(:todos, [:user_id, :id], where: "state='done'", name: INDEX_NAME_DONE)
end end
end end
...@@ -6,6 +6,7 @@ class RenameUsersRssTokenToFeedToken < ActiveRecord::Migration ...@@ -6,6 +6,7 @@ class RenameUsersRssTokenToFeedToken < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
def up def up
# rubocop:disable Migration/UpdateLargeTable
rename_column_concurrently :users, :rss_token, :feed_token rename_column_concurrently :users, :rss_token, :feed_token
end end
......
...@@ -26,6 +26,7 @@ class AddIndexConstraintsToInternalIdTable < ActiveRecord::Migration ...@@ -26,6 +26,7 @@ class AddIndexConstraintsToInternalIdTable < ActiveRecord::Migration
end end
private private
def replace_index(table, columns, name:) def replace_index(table, columns, name:)
temporary_name = "#{name}_old" temporary_name = "#{name}_old"
......
...@@ -10,6 +10,7 @@ class AddIndexToCiJobArtifactsFileStore < ActiveRecord::Migration ...@@ -10,6 +10,7 @@ class AddIndexToCiJobArtifactsFileStore < ActiveRecord::Migration
end end
def down def down
# rubocop:disable Migration/RemoveIndex
remove_index :ci_job_artifacts, :file_store if index_exists?(:ci_job_artifacts, :file_store) remove_index :ci_job_artifacts, :file_store if index_exists?(:ci_job_artifacts, :file_store)
end end
end end
...@@ -4,6 +4,7 @@ class AddEnforceTermsToApplicationSettings < ActiveRecord::Migration ...@@ -4,6 +4,7 @@ class AddEnforceTermsToApplicationSettings < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
def change def change
# rubocop:disable Migration/SaferBooleanColumn
add_column :application_settings, :enforce_terms, :boolean, default: false add_column :application_settings, :enforce_terms, :boolean, default: false
end end
end end
...@@ -21,6 +21,7 @@ class CreateTermAgreements < ActiveRecord::Migration ...@@ -21,6 +21,7 @@ class CreateTermAgreements < ActiveRecord::Migration
end end
def down 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 drop_table :term_agreements
......
...@@ -23,6 +23,7 @@ class CreateRemoteMirrors < ActiveRecord::Migration ...@@ -23,6 +23,7 @@ class CreateRemoteMirrors < ActiveRecord::Migration
t.string :encrypted_credentials_iv t.string :encrypted_credentials_iv
t.string :encrypted_credentials_salt t.string :encrypted_credentials_salt
# rubocop:disable Migration/Timestamps
t.timestamps null: false t.timestamps null: false
end end
end end
......
...@@ -14,6 +14,7 @@ class AddIndexToNamespacesRunnersToken < ActiveRecord::Migration ...@@ -14,6 +14,7 @@ class AddIndexToNamespacesRunnersToken < ActiveRecord::Migration
def down def down
if index_exists?(:namespaces, :runners_token, unique: true) if index_exists?(:namespaces, :runners_token, unique: true)
# rubocop:disable Migration/RemoveIndex
remove_index :namespaces, :runners_token remove_index :namespaces, :runners_token
end end
end end
......
...@@ -11,6 +11,7 @@ class AddIndexesToProjectMirrorData < ActiveRecord::Migration ...@@ -11,6 +11,7 @@ class AddIndexesToProjectMirrorData < ActiveRecord::Migration
end end
def down def down
# rubocop:disable Migration/RemoveIndex
remove_index :project_mirror_data, :jid if index_exists? :project_mirror_data, :jid remove_index :project_mirror_data, :jid if index_exists? :project_mirror_data, :jid
remove_index :project_mirror_data, :status if index_exists? :project_mirror_data, :status remove_index :project_mirror_data, :status if index_exists? :project_mirror_data, :status
end end
......
...@@ -11,5 +11,7 @@ class AddIndexesToRemoteMirror < ActiveRecord::Migration ...@@ -11,5 +11,7 @@ class AddIndexesToRemoteMirror < ActiveRecord::Migration
def down def down
# ee/db/migrate/20170208144550_add_index_to_mirrors_last_update_at_fields.rb will remove the index. # ee/db/migrate/20170208144550_add_index_to_mirrors_last_update_at_fields.rb will remove the index.
# rubocop:disable Migration/RemoveIndex
remove_index :remote_mirrors, :last_successful_update_at if index_exists? :remote_mirrors, :last_successful_update_at
end end
end end
...@@ -10,6 +10,7 @@ class AddIndexOnCiRunnersRunnerType < ActiveRecord::Migration ...@@ -10,6 +10,7 @@ class AddIndexOnCiRunnersRunnerType < ActiveRecord::Migration
end end
def down def down
# rubocop:disable Migration/RemoveIndex
remove_index :ci_runners, :runner_type remove_index :ci_runners, :runner_type
end end
end end
...@@ -9,6 +9,7 @@ class AddSquashToMergeRequests < ActiveRecord::Migration ...@@ -9,6 +9,7 @@ class AddSquashToMergeRequests < ActiveRecord::Migration
def up def up
unless column_exists?(:merge_requests, :squash) unless column_exists?(:merge_requests, :squash)
# rubocop:disable Migration/UpdateLargeTable
add_column_with_default :merge_requests, :squash, :boolean, default: false, allow_null: false add_column_with_default :merge_requests, :squash, :boolean, default: false, allow_null: false
end end
end end
......
...@@ -16,6 +16,7 @@ class CreateNotesDiffFiles < ActiveRecord::Migration ...@@ -16,6 +16,7 @@ class CreateNotesDiffFiles < ActiveRecord::Migration
t.text :old_path, null: false t.text :old_path, null: false
end end
# rubocop:disable Migration/AddConcurrentForeignKey
add_foreign_key :note_diff_files, :notes, column: :diff_note_id, on_delete: :cascade add_foreign_key :note_diff_files, :notes, column: :diff_note_id, on_delete: :cascade
end end
end end
# rubocop:disable all
require_relative 'gpg_keys_limits_to_mysql' require_relative 'gpg_keys_limits_to_mysql'
...@@ -6,6 +6,7 @@ class EnsureRemoteMirrorColumns < ActiveRecord::Migration ...@@ -6,6 +6,7 @@ class EnsureRemoteMirrorColumns < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
def up def up
# rubocop:disable Migration/Datetime
add_column :remote_mirrors, :last_update_started_at, :datetime unless column_exists?(:remote_mirrors, :last_update_started_at) add_column :remote_mirrors, :last_update_started_at, :datetime unless column_exists?(:remote_mirrors, :last_update_started_at)
add_column :remote_mirrors, :remote_name, :string unless column_exists?(:remote_mirrors, :remote_name) add_column :remote_mirrors, :remote_name, :string unless column_exists?(:remote_mirrors, :remote_name)
......
...@@ -4,13 +4,13 @@ class ChangeDefaultValueForDsaKeyRestriction < ActiveRecord::Migration ...@@ -4,13 +4,13 @@ class ChangeDefaultValueForDsaKeyRestriction < ActiveRecord::Migration
def up def up
change_column :application_settings, :dsa_key_restriction, :integer, null: false, change_column :application_settings, :dsa_key_restriction, :integer, null: false,
default: -1 default: -1
execute("UPDATE application_settings SET dsa_key_restriction = -1") execute("UPDATE application_settings SET dsa_key_restriction = -1")
end end
def down def down
change_column :application_settings, :dsa_key_restriction, :integer, null: false, change_column :application_settings, :dsa_key_restriction, :integer, null: false,
default: 0 default: 0
end end
end end
...@@ -11,6 +11,7 @@ class RenameMergeRequestsAllowCollaboration < ActiveRecord::Migration ...@@ -11,6 +11,7 @@ class RenameMergeRequestsAllowCollaboration < ActiveRecord::Migration
def up def up
if column_exists?(:merge_requests, :allow_collaboration) if column_exists?(:merge_requests, :allow_collaboration)
# rubocop:disable Migration/UpdateLargeTable
rename_column_concurrently :merge_requests, :allow_collaboration, :allow_maintainer_to_push rename_column_concurrently :merge_requests, :allow_collaboration, :allow_maintainer_to_push
end end
end end
......
class IncreaseMysqlTextLimitForGpgKeys < ActiveRecord::Migration class IncreaseMysqlTextLimitForGpgKeys < ActiveRecord::Migration
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
......
...@@ -4,6 +4,6 @@ class LimitsCiBuildTraceChunksRawDataForMysql < ActiveRecord::Migration ...@@ -4,6 +4,6 @@ class LimitsCiBuildTraceChunksRawDataForMysql < ActiveRecord::Migration
# Mysql needs MEDIUMTEXT type (up to 16MB) rather than TEXT (up to 64KB) # Mysql needs MEDIUMTEXT type (up to 16MB) rather than TEXT (up to 64KB)
# Because 'raw_data' is always capped by Ci::BuildTraceChunk::CHUNK_SIZE, which is 128KB # Because 'raw_data' is always capped by Ci::BuildTraceChunk::CHUNK_SIZE, which is 128KB
change_column :ci_build_trace_chunks, :raw_data, :binary, limit: 16.megabytes - 1 #MEDIUMTEXT change_column :ci_build_trace_chunks, :raw_data, :binary, limit: 16.megabytes - 1 # MEDIUMTEXT
end end
end end
# rubocop:disable all
class LimitsToMysql < ActiveRecord::Migration class LimitsToMysql < ActiveRecord::Migration
def up def up
return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/ return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/
......
...@@ -21,8 +21,8 @@ class CompositePrimaryKeysMigration < ActiveRecord::Migration ...@@ -21,8 +21,8 @@ class CompositePrimaryKeysMigration < ActiveRecord::Migration
Index.new(:merge_request_diff_commits, 'index_merge_request_diff_commits_on_mr_diff_id_and_order', %i(merge_request_diff_id relative_order)), Index.new(:merge_request_diff_commits, 'index_merge_request_diff_commits_on_mr_diff_id_and_order', %i(merge_request_diff_id relative_order)),
Index.new(:project_authorizations, 'index_project_authorizations_on_user_id_project_id_access_level', %i(user_id project_id access_level)), Index.new(:project_authorizations, 'index_project_authorizations_on_user_id_project_id_access_level', %i(user_id project_id access_level)),
Index.new(:push_event_payloads, 'index_push_event_payloads_on_event_id', %i(event_id)), Index.new(:push_event_payloads, 'index_push_event_payloads_on_event_id', %i(event_id)),
Index.new(:schema_migrations, 'unique_schema_migrations', %(version)), Index.new(:schema_migrations, 'unique_schema_migrations', %(version))
] ].freeze
disable_ddl_transaction! disable_ddl_transaction!
...@@ -45,6 +45,7 @@ class CompositePrimaryKeysMigration < ActiveRecord::Migration ...@@ -45,6 +45,7 @@ class CompositePrimaryKeysMigration < ActiveRecord::Migration
end end
private private
def add_primary_key(index) def add_primary_key(index)
execute "ALTER TABLE #{index.table} ADD PRIMARY KEY USING INDEX #{index.name}" execute "ALTER TABLE #{index.table} ADD PRIMARY KEY USING INDEX #{index.name}"
end end
...@@ -60,4 +61,3 @@ class CompositePrimaryKeysMigration < ActiveRecord::Migration ...@@ -60,4 +61,3 @@ class CompositePrimaryKeysMigration < ActiveRecord::Migration
execute "ALTER TABLE #{index.table} DROP CONSTRAINT IF EXISTS #{temp_index_name}" execute "ALTER TABLE #{index.table} DROP CONSTRAINT IF EXISTS #{temp_index_name}"
end end
end end
...@@ -124,7 +124,7 @@ class RenameReservedProjectNames < ActiveRecord::Migration ...@@ -124,7 +124,7 @@ class RenameReservedProjectNames < ActiveRecord::Migration
def rename_project_row(project, path) def rename_project_row(project, path)
project.respond_to?(:update_attributes) && project.respond_to?(:update_attributes) &&
project.update_attributes(path: path) && project.update(path: path) &&
project.respond_to?(:rename_repo) project.respond_to?(:rename_repo)
end end
end end
...@@ -66,7 +66,7 @@ class RenameMoreReservedProjectNames < ActiveRecord::Migration ...@@ -66,7 +66,7 @@ class RenameMoreReservedProjectNames < ActiveRecord::Migration
def rename_project_row(project, path) def rename_project_row(project, path)
project.respond_to?(:update_attributes) && project.respond_to?(:update_attributes) &&
project.update_attributes(path: path) && project.update(path: path) &&
project.respond_to?(:rename_repo) project.respond_to?(:rename_repo)
end end
end end
# rubocop:disable Migration/Datetime
class DropCiTriggerSchedulesTable < ActiveRecord::Migration class DropCiTriggerSchedulesTable < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
...@@ -10,6 +10,7 @@ class CleanupUsersLdapEmailRename < ActiveRecord::Migration ...@@ -10,6 +10,7 @@ class CleanupUsersLdapEmailRename < ActiveRecord::Migration
end end
def down def down
# rubocop:disable Migration/UpdateLargeTable
rename_column_concurrently :users, :external_email, :ldap_email rename_column_concurrently :users, :external_email, :ldap_email
end end
end end
...@@ -28,6 +28,7 @@ class MigrateStagesStatuses < ActiveRecord::Migration ...@@ -28,6 +28,7 @@ class MigrateStagesStatuses < ActiveRecord::Migration
def down def down
disable_statement_timeout disable_statement_timeout
# rubocop:disable Migration/UpdateLargeTable
update_column_in_batches(:ci_stages, :status, nil) update_column_in_batches(:ci_stages, :status, nil)
end end
end end
...@@ -18,7 +18,6 @@ class DropEventsForMigrationTable < ActiveRecord::Migration ...@@ -18,7 +18,6 @@ class DropEventsForMigrationTable < ActiveRecord::Migration
end end
end end
# rubocop: disable Migration/Datetime
def down def down
create_table :events_for_migration do |t| create_table :events_for_migration do |t|
t.string :target_type, index: true t.string :target_type, index: true
......
# rubocop:disable Migration/RemoveColumn
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
......
...@@ -13,6 +13,7 @@ class CleanupAddTimezoneToIssuesClosedAt < ActiveRecord::Migration ...@@ -13,6 +13,7 @@ class CleanupAddTimezoneToIssuesClosedAt < ActiveRecord::Migration
end end
# rubocop:disable Migration/Datetime # rubocop:disable Migration/Datetime
# rubocop:disable Migration/UpdateLargeTable
def down def down
change_column_type_concurrently(:issues, :closed_at, :datetime) change_column_type_concurrently(:issues, :closed_at, :datetime)
end end
......
# frozen_string_literal: true # frozen_string_literal: true
# rubocop:disable GitlabSecurity/SqlInjection
class SchedulePopulateMergeRequestMetricsWithEventsData < ActiveRecord::Migration class SchedulePopulateMergeRequestMetricsWithEventsData < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
......
...@@ -43,8 +43,6 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration ...@@ -43,8 +43,6 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration
end end
end end
private
class PostgresStrategy < ActiveRecord::Migration class PostgresStrategy < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
...@@ -79,6 +77,7 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration ...@@ -79,6 +77,7 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration
end end
private private
def insert_missing_records def insert_missing_records
iteration = 0 iteration = 0
records = 0 records = 0
......
...@@ -8,6 +8,7 @@ class CleanupUsersRssTokenRename < ActiveRecord::Migration ...@@ -8,6 +8,7 @@ class CleanupUsersRssTokenRename < ActiveRecord::Migration
end end
def down def down
# rubocop:disable Migration/UpdateLargeTable
rename_column_concurrently :users, :feed_token, :rss_token rename_column_concurrently :users, :feed_token, :rss_token
end end
end end
...@@ -38,7 +38,7 @@ class FillFileStore < ActiveRecord::Migration ...@@ -38,7 +38,7 @@ class FillFileStore < ActiveRecord::Migration
def up def up
# NOTE: Schedule background migrations that fill 'NULL' value by '1'(ObjectStorage::Store::LOCAL) on `file_store`, `store` columns # NOTE: Schedule background migrations that fill 'NULL' value by '1'(ObjectStorage::Store::LOCAL) on `file_store`, `store` columns
# #
# Here are the target columns # Here are the target columns
# - ci_job_artifacts.file_store # - ci_job_artifacts.file_store
# - lfs_objects.file_store # - lfs_objects.file_store
......
...@@ -9,6 +9,7 @@ class BackfillRunnerTypeForCiRunnersPostMigrate < ActiveRecord::Migration ...@@ -9,6 +9,7 @@ class BackfillRunnerTypeForCiRunnersPostMigrate < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
def up def up
# rubocop:disable Migration/UpdateColumnInBatches
update_column_in_batches(:ci_runners, :runner_type, INSTANCE_RUNNER_TYPE) do |table, query| update_column_in_batches(:ci_runners, :runner_type, INSTANCE_RUNNER_TYPE) do |table, query|
query.where(table[:is_shared].eq(true)).where(table[:runner_type].eq(nil)) query.where(table[:is_shared].eq(true)).where(table[:runner_type].eq(nil))
end end
......
...@@ -8,6 +8,8 @@ class SetMinimalProjectBuildTimeout < ActiveRecord::Migration ...@@ -8,6 +8,8 @@ class SetMinimalProjectBuildTimeout < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
def up def up
# rubocop:disable Migration/UpdateLargeTable
# rubocop:disable Migration/UpdateColumnInBatches
update_column_in_batches(:projects, :build_timeout, MINIMUM_TIMEOUT) do |table, query| update_column_in_batches(:projects, :build_timeout, MINIMUM_TIMEOUT) do |table, query|
query.where(table[:build_timeout].lt(MINIMUM_TIMEOUT)) query.where(table[:build_timeout].lt(MINIMUM_TIMEOUT))
end end
......
...@@ -11,6 +11,7 @@ class CleanupMergeRequestsAllowMaintainerToPushRename < ActiveRecord::Migration ...@@ -11,6 +11,7 @@ class CleanupMergeRequestsAllowMaintainerToPushRename < ActiveRecord::Migration
def down def down
if column_exists?(:merge_requests, :allow_collaboration) if column_exists?(:merge_requests, :allow_collaboration)
# rubocop:disable Migration/UpdateLargeTable
rename_column_concurrently :merge_requests, :allow_collaboration, :allow_maintainer_to_push rename_column_concurrently :merge_requests, :allow_collaboration, :allow_maintainer_to_push
end end
end end
......
...@@ -14,7 +14,7 @@ class UpdateProjectIndexes < ActiveRecord::Migration ...@@ -14,7 +14,7 @@ class UpdateProjectIndexes < ActiveRecord::Migration
[:repository_storage, :created_at], [:repository_storage, :created_at],
name: NEW_INDEX_NAME, name: NEW_INDEX_NAME,
where: 'last_repository_check_at IS NULL' where: 'last_repository_check_at IS NULL'
) )
end end
def down def down
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment