Commit d3ac3c94 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Fix Rubocop offenses for EE migrations

parent 43971ef2
# rubocop:disable Migration/Timestamps
# rubocop:disable Migration/Datetime
class CreateUserActivities < ActiveRecord::Migration class CreateUserActivities < ActiveRecord::Migration
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = true DOWNTIME = true
......
# 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 DropUserActivitiesTable < ActiveRecord::Migration class DropUserActivitiesTable < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
...@@ -12,13 +12,13 @@ class AddPartialIndexProjectRepositoryVerification < ActiveRecord::Migration ...@@ -12,13 +12,13 @@ class AddPartialIndexProjectRepositoryVerification < ActiveRecord::Migration
[:project_id], [:project_id],
name: REPO_INDEX_NAME, name: REPO_INDEX_NAME,
where: 'repository_verification_checksum_sha IS NULL AND last_repository_verification_failure IS NULL' where: 'repository_verification_checksum_sha IS NULL AND last_repository_verification_failure IS NULL'
) )
add_concurrent_index(:project_registry, add_concurrent_index(:project_registry,
[:project_id], [:project_id],
name: WIKI_INDEX_NAME, name: WIKI_INDEX_NAME,
where: 'wiki_verification_checksum_sha IS NULL AND last_wiki_verification_failure IS NULL' where: 'wiki_verification_checksum_sha IS NULL AND last_wiki_verification_failure IS NULL'
) )
end end
def down def down
......
class SetResyncFlagForRetriedProjects < ActiveRecord::Migration class SetResyncFlagForRetriedProjects < ActiveRecord::Migration
def up def up
execute <<-SQL execute <<-SQL
UPDATE project_registry SET resync_repository = 't' WHERE repository_retry_count > 0 AND resync_repository = 'f'; UPDATE project_registry SET resync_repository = 't' WHERE repository_retry_count > 0 AND resync_repository = 'f';
UPDATE project_registry SET resync_wiki = 't' WHERE wiki_retry_count > 0 AND resync_wiki = 'f'; UPDATE project_registry SET resync_wiki = 't' WHERE wiki_retry_count > 0 AND resync_wiki = 'f';
SQL SQL
......
# rubocop:disable Rails/ReversibleMigration
class UpdateGroupLinks < ActiveRecord::Migration class UpdateGroupLinks < ActiveRecord::Migration
def change def change
provider = quote_string(Gitlab::Auth::LDAP::Config.providers.first) provider = quote_string(Gitlab::Auth::LDAP::Config.providers.first)
......
...@@ -19,6 +19,7 @@ class CanonicalizeKerberosIdentities < ActiveRecord::Migration ...@@ -19,6 +19,7 @@ class CanonicalizeKerberosIdentities < ActiveRecord::Migration
def change def change
reversible do |dir| reversible do |dir|
# rubocop:disable Cop/AvoidReturnFromBlocks
return unless kerberos_default_realm.present? return unless kerberos_default_realm.present?
dir.up do dir.up do
......
# rubocop:disable Migration/Timestamps # rubocop:disable Migration/Timestamps
# rubocop:disable Migration/Datetime
class CreateIndexStatuses < ActiveRecord::Migration class CreateIndexStatuses < ActiveRecord::Migration
def change def change
create_table :index_statuses do |t| create_table :index_statuses do |t|
......
# rubocop:disable Migration/Datetime
# rubocop:disable Migration/Timestamps # rubocop:disable Migration/Timestamps
class CreateRemoteMirrorsEE < ActiveRecord::Migration class CreateRemoteMirrorsEE < ActiveRecord::Migration
def up def up
......
# Migration type: online without errors (works on previous version and new one) # Migration type: online without errors (works on previous version and new one)
# rubocop:disable Migration/AddColumnWithDefaultToLargeTable
# rubocop:disable Migration/Datetime # rubocop:disable Migration/Datetime
# rubocop:disable Migration/UpdateLargeTable # rubocop:disable Migration/UpdateLargeTable
class AddLdapSyncStateToGroups < ActiveRecord::Migration class AddLdapSyncStateToGroups < ActiveRecord::Migration
......
# rubocop:disable Migration/AddColumnWithDefaultToLargeTable
# rubocop:disable Migration/UpdateLargeTable # rubocop:disable Migration/UpdateLargeTable
class AddSquashToMergeRequestsEE < ActiveRecord::Migration class AddSquashToMergeRequestsEE < 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/AddColumnWithDefaultToLargeTable
# rubocop:disable Migration/UpdateLargeTable # rubocop:disable Migration/UpdateLargeTable
class AddColumnAuditorToUsers < ActiveRecord::Migration class AddColumnAuditorToUsers < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable Migration/AddColumnWithDefaultToLargeTable
# rubocop:disable Migration/UpdateLargeTable # rubocop:disable Migration/UpdateLargeTable
class AddSyncScheduleToProjectsAndRemoteProjects < ActiveRecord::Migration class AddSyncScheduleToProjectsAndRemoteProjects < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
......
# rubocop:disable Migration/Datetime
class CreateGeoRepositoryUpdatedEvents < ActiveRecord::Migration class CreateGeoRepositoryUpdatedEvents < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
......
# rubocop:disable Migration/Datetime
class CreateGeoEventLog < ActiveRecord::Migration class CreateGeoEventLog < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
......
class CreateProjectRepositoryStates < ActiveRecord::Migration class CreateProjectRepositoryStates < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
def change def change
......
...@@ -18,6 +18,7 @@ class CreateChatopsTables < ActiveRecord::Migration ...@@ -18,6 +18,7 @@ class CreateChatopsTables < ActiveRecord::Migration
t.index :pipeline_id, unique: true t.index :pipeline_id, unique: true
end end
# rubocop:disable Migration/AddConcurrentForeignKey
add_foreign_key :ci_pipeline_chat_data, :ci_pipelines, add_foreign_key :ci_pipeline_chat_data, :ci_pipelines,
column: :pipeline_id, column: :pipeline_id,
on_delete: :cascade on_delete: :cascade
......
...@@ -13,7 +13,7 @@ class AddPartialIndexToProjectRepositoryStatesChecksumColumns < ActiveRecord::Mi ...@@ -13,7 +13,7 @@ class AddPartialIndexToProjectRepositoryStatesChecksumColumns < ActiveRecord::Mi
name: INDEX_NAME, name: INDEX_NAME,
length: Gitlab::Database.mysql? ? 20 : nil, length: Gitlab::Database.mysql? ? 20 : nil,
where: 'repository_verification_checksum IS NULL OR wiki_verification_checksum IS NULL' where: 'repository_verification_checksum IS NULL OR wiki_verification_checksum IS NULL'
) )
end end
end end
......
class AddExternalAuthMutualTlsFieldsToProjectSettings < ActiveRecord::Migration class AddExternalAuthMutualTlsFieldsToProjectSettings < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
def change def change
......
...@@ -5,7 +5,7 @@ class DropNullConstraintGeoEventsStoragePath < ActiveRecord::Migration ...@@ -5,7 +5,7 @@ class DropNullConstraintGeoEventsStoragePath < ActiveRecord::Migration
TABLES = %i(geo_hashed_storage_migrated_events geo_repository_created_events TABLES = %i(geo_hashed_storage_migrated_events geo_repository_created_events
geo_repository_deleted_events geo_repository_renamed_events) geo_repository_deleted_events geo_repository_renamed_events)
def up def up
TABLES.each do |table| TABLES.each do |table|
change_column_null(table, :repository_storage_path, true) change_column_null(table, :repository_storage_path, true)
end end
......
...@@ -11,4 +11,3 @@ class AddNegativeMatchingCommitMessagePushRule < ActiveRecord::Migration ...@@ -11,4 +11,3 @@ class AddNegativeMatchingCommitMessagePushRule < ActiveRecord::Migration
remove_column :push_rules, :commit_message_negative_regex remove_column :push_rules, :commit_message_negative_regex
end end
end end
...@@ -10,6 +10,7 @@ class AddIndexesToProjectMirrorDataEE < ActiveRecord::Migration ...@@ -10,6 +10,7 @@ class AddIndexesToProjectMirrorDataEE < ActiveRecord::Migration
end end
def down def down
# rubocop:disable Migration/RemoveIndex
remove_index :project_mirror_data, :last_successful_update_at if index_exists? :project_mirror_data, :last_successful_update_at remove_index :project_mirror_data, :last_successful_update_at if index_exists? :project_mirror_data, :last_successful_update_at
end end
end end
...@@ -4,6 +4,7 @@ class AddGeoNodesVerificationMaxCapacity < ActiveRecord::Migration ...@@ -4,6 +4,7 @@ class AddGeoNodesVerificationMaxCapacity < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
def change def change
# rubocop:disable Migration/AddColumn
add_column :geo_nodes, :verification_max_capacity, :integer, default: 100, null: false add_column :geo_nodes, :verification_max_capacity, :integer, default: 100, null: false
end end
end end
...@@ -29,6 +29,7 @@ class DropRepositoryStorageEventsForGeoEvents < ActiveRecord::Migration ...@@ -29,6 +29,7 @@ class DropRepositoryStorageEventsForGeoEvents < ActiveRecord::Migration
private private
def update_repository_storage_path(table) def update_repository_storage_path(table)
# rubocop:disable Migration/UpdateColumnInBatches
update_column_in_batches(table, :repository_storage_path, update_statement) do |t, q| update_column_in_batches(table, :repository_storage_path, update_statement) do |t, q|
q.where(t[:repository_storage_path].eq(nil)) q.where(t[:repository_storage_path].eq(nil))
end end
......
...@@ -98,7 +98,7 @@ class MigrateMirrorAttributesDataFromProjectsToImportState < ActiveRecord::Migra ...@@ -98,7 +98,7 @@ class MigrateMirrorAttributesDataFromProjectsToImportState < ActiveRecord::Migra
execute <<~SQL execute <<~SQL
UPDATE project_mirror_data UPDATE project_mirror_data
SET status = 'none' SET status = 'none'
FROM projects FROM projects
WHERE projects.id = project_id WHERE projects.id = project_id
AND projects.mirror = TRUE AND projects.mirror = TRUE
AND projects.id BETWEEN #{start} AND #{stop} AND projects.id BETWEEN #{start} AND #{stop}
......
...@@ -14,7 +14,7 @@ class FixPartialIndexToProjectRepositoryStatesChecksumColumns < ActiveRecord::Mi ...@@ -14,7 +14,7 @@ class FixPartialIndexToProjectRepositoryStatesChecksumColumns < ActiveRecord::Mi
:project_id, :project_id,
name: NEW_INDEX_NAME, name: NEW_INDEX_NAME,
where: '(repository_verification_checksum IS NULL AND last_repository_verification_failure is NULL) OR (wiki_verification_checksum IS NULL AND last_wiki_verification_failure IS NULL)' where: '(repository_verification_checksum IS NULL AND last_repository_verification_failure is NULL) OR (wiki_verification_checksum IS NULL AND last_wiki_verification_failure IS NULL)'
) )
end end
def down def down
...@@ -25,6 +25,6 @@ class FixPartialIndexToProjectRepositoryStatesChecksumColumns < ActiveRecord::Mi ...@@ -25,6 +25,6 @@ class FixPartialIndexToProjectRepositoryStatesChecksumColumns < ActiveRecord::Mi
name: OLD_INDEX_NAME, name: OLD_INDEX_NAME,
length: Gitlab::Database.mysql? ? 20 : nil, length: Gitlab::Database.mysql? ? 20 : nil,
where: 'repository_verification_checksum IS NULL OR wiki_verification_checksum IS NULL' where: 'repository_verification_checksum IS NULL OR wiki_verification_checksum IS NULL'
) )
end end
end end
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