Commit 371032d9 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'tc-geo-migrations-cop' into 'master'

Enable migration cops for Geo migrations tool

Closes #13814

See merge request gitlab-org/gitlab!16697
parents 767b5d77 136d0f48
class CreateFileRegistry < ActiveRecord::Migration[4.2] class CreateFileRegistry < ActiveRecord::Migration[4.2]
def change def change
create_table :file_registry do |t| create_table :file_registry do |t|
t.string :file_type, null: false t.string :file_type, null: false # rubocop:disable Migration/AddLimitToStringColumns
t.integer :file_id, null: false t.integer :file_id, null: false
t.integer :bytes t.integer :bytes
t.string :sha256 t.string :sha256 # rubocop:disable Migration/AddLimitToStringColumns
t.datetime :created_at, null: false t.datetime :created_at, null: false
end end
......
...@@ -10,6 +10,6 @@ class AddIndexToProjectIdOnProjectRegistry < ActiveRecord::Migration[4.2] ...@@ -10,6 +10,6 @@ class AddIndexToProjectIdOnProjectRegistry < ActiveRecord::Migration[4.2]
end end
def down def down
remove_index :project_registry, :project_id remove_concurrent_index :project_registry, :project_id
end end
end end
...@@ -2,7 +2,7 @@ class AddLastWikiSyncedAtToProjectRegistry < ActiveRecord::Migration[4.2] ...@@ -2,7 +2,7 @@ class AddLastWikiSyncedAtToProjectRegistry < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :project_registry, :last_wiki_synced_at, :datetime add_column :project_registry, :last_wiki_synced_at, :datetime # rubocop:disable Migration/Datetime
add_column :project_registry, :last_wiki_successful_sync_at, :datetime add_column :project_registry, :last_wiki_successful_sync_at, :datetime # rubocop:disable Migration/Datetime
end end
end end
...@@ -7,14 +7,14 @@ class AddRetryCountFieldsToRegistries < ActiveRecord::Migration[4.2] ...@@ -7,14 +7,14 @@ class AddRetryCountFieldsToRegistries < ActiveRecord::Migration[4.2]
def up def up
add_column :file_registry, :retry_count, :integer add_column :file_registry, :retry_count, :integer
add_column :file_registry, :retry_at, :datetime add_column :file_registry, :retry_at, :datetime # rubocop:disable Migration/Datetime
add_column :project_registry, :repository_retry_count, :integer add_column :project_registry, :repository_retry_count, :integer
add_column :project_registry, :repository_retry_at, :datetime add_column :project_registry, :repository_retry_at, :datetime # rubocop:disable Migration/Datetime
add_column :project_registry, :force_to_redownload_repository, :boolean add_column :project_registry, :force_to_redownload_repository, :boolean
add_column :project_registry, :wiki_retry_count, :integer add_column :project_registry, :wiki_retry_count, :integer
add_column :project_registry, :wiki_retry_at, :datetime add_column :project_registry, :wiki_retry_at, :datetime # rubocop:disable Migration/Datetime
add_column :project_registry, :force_to_redownload_wiki, :boolean add_column :project_registry, :force_to_redownload_wiki, :boolean
# Indecies # Indecies
...@@ -25,14 +25,14 @@ class AddRetryCountFieldsToRegistries < ActiveRecord::Migration[4.2] ...@@ -25,14 +25,14 @@ class AddRetryCountFieldsToRegistries < ActiveRecord::Migration[4.2]
def down def down
remove_column :file_registry, :retry_count, :integer remove_column :file_registry, :retry_count, :integer
remove_column :file_registry, :retry_at, :datetime remove_column :file_registry, :retry_at, :datetime # rubocop:disable Migration/Datetime
remove_column :project_registry, :repository_retry_count, :integer remove_column :project_registry, :repository_retry_count, :integer
remove_column :project_registry, :repository_retry_at, :datetime remove_column :project_registry, :repository_retry_at, :datetime # rubocop:disable Migration/Datetime
remove_column :project_registry, :force_to_redownload_repository, :boolean remove_column :project_registry, :force_to_redownload_repository, :boolean
remove_column :project_registry, :wiki_retry_count, :integer remove_column :project_registry, :wiki_retry_count, :integer
remove_column :project_registry, :wiki_retry_at, :datetime remove_column :project_registry, :wiki_retry_at, :datetime # rubocop:disable Migration/Datetime
remove_column :project_registry, :force_to_redownload_wiki, :boolean remove_column :project_registry, :force_to_redownload_wiki, :boolean
end end
end end
...@@ -2,7 +2,7 @@ class AddLastSyncFailureToProjectRegistry < ActiveRecord::Migration[4.2] ...@@ -2,7 +2,7 @@ class AddLastSyncFailureToProjectRegistry < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :project_registry, :last_repository_sync_failure, :string add_column :project_registry, :last_repository_sync_failure, :string # rubocop:disable Migration/AddLimitToStringColumns
add_column :project_registry, :last_wiki_sync_failure, :string add_column :project_registry, :last_wiki_sync_failure, :string # rubocop:disable Migration/AddLimitToStringColumns
end end
end end
...@@ -5,14 +5,14 @@ class AddRepositoryVerificationToProjectRegistry < ActiveRecord::Migration[4.2] ...@@ -5,14 +5,14 @@ class AddRepositoryVerificationToProjectRegistry < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :project_registry, :repository_verification_checksum, :string add_column :project_registry, :repository_verification_checksum, :string # rubocop:disable Migration/AddLimitToStringColumns
add_column :project_registry, :last_repository_verification_at, :datetime_with_timezone add_column :project_registry, :last_repository_verification_at, :datetime_with_timezone
add_column :project_registry, :last_repository_verification_failed, :boolean, null: false, default: false add_column :project_registry, :last_repository_verification_failed, :boolean, null: false, default: false # rubocop:disable Migration/AddColumn
add_column :project_registry, :last_repository_verification_failure, :string add_column :project_registry, :last_repository_verification_failure, :string # rubocop:disable Migration/AddLimitToStringColumns
add_column :project_registry, :wiki_verification_checksum, :string add_column :project_registry, :wiki_verification_checksum, :string # rubocop:disable Migration/AddLimitToStringColumns
add_column :project_registry, :last_wiki_verification_at, :datetime_with_timezone add_column :project_registry, :last_wiki_verification_at, :datetime_with_timezone
add_column :project_registry, :last_wiki_verification_failed, :boolean, null: false, default: false add_column :project_registry, :last_wiki_verification_failed, :boolean, null: false, default: false # rubocop:disable Migration/AddColumn
add_column :project_registry, :last_wiki_verification_failure, :string add_column :project_registry, :last_wiki_verification_failure, :string # rubocop:disable Migration/AddLimitToStringColumns
end end
end end
...@@ -7,7 +7,7 @@ class MigrateCiJobArtifactsToSeparateRegistry < ActiveRecord::Migration[4.2] ...@@ -7,7 +7,7 @@ class MigrateCiJobArtifactsToSeparateRegistry < ActiveRecord::Migration[4.2]
t.integer "artifact_id", unique: true t.integer "artifact_id", unique: true
t.integer "retry_count" t.integer "retry_count"
t.boolean "success" t.boolean "success"
t.string "sha256" t.string "sha256" # rubocop:disable Migration/AddLimitToStringColumns
end end
Geo::TrackingBase.transaction do Geo::TrackingBase.transaction do
......
...@@ -4,7 +4,7 @@ class AddChecksumMismatchFieldsToProjectRegistry < ActiveRecord::Migration[4.2] ...@@ -4,7 +4,7 @@ class AddChecksumMismatchFieldsToProjectRegistry < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :project_registry, :repository_checksum_mismatch, :boolean, null: false, default: false add_column :project_registry, :repository_checksum_mismatch, :boolean, null: false, default: false # rubocop:disable Migration/AddColumn
add_column :project_registry, :wiki_checksum_mismatch, :boolean, null: false, default: false add_column :project_registry, :wiki_checksum_mismatch, :boolean, null: false, default: false # rubocop:disable Migration/AddColumn
end end
end end
...@@ -6,9 +6,9 @@ class AddContainerRepositoryRegistry < ActiveRecord::Migration[5.0] ...@@ -6,9 +6,9 @@ class AddContainerRepositoryRegistry < ActiveRecord::Migration[5.0]
def change def change
create_table :container_repository_registry, id: :serial, force: :cascade do |t| create_table :container_repository_registry, id: :serial, force: :cascade do |t|
t.integer :container_repository_id, null: false t.integer :container_repository_id, null: false
t.string :state t.string :state # rubocop:disable Migration/AddLimitToStringColumns
t.integer :retry_count, default: 0 t.integer :retry_count, default: 0
t.string :last_sync_failure t.string :last_sync_failure # rubocop:disable Migration/AddLimitToStringColumns
t.datetime :retry_at t.datetime :retry_at
t.datetime :last_synced_at t.datetime :last_synced_at
t.datetime :created_at, null: false t.datetime :created_at, null: false
......
...@@ -4,7 +4,7 @@ class AddCreatedAtToEventLogStates < ActiveRecord::Migration[5.2] ...@@ -4,7 +4,7 @@ class AddCreatedAtToEventLogStates < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
def up def up
add_column(:event_log_states, :created_at, :datetime, null: true) add_column(:event_log_states, :created_at, :datetime, null: true) # rubocop:disable Migration/Datetime
# There should only be 1 record in the event_log_states table # There should only be 1 record in the event_log_states table
execute('UPDATE event_log_states SET created_at = ( execute('UPDATE event_log_states SET created_at = (
......
...@@ -7,7 +7,7 @@ class RemoveLastVerificationFailedColumnsFromGeoProjectRegistry < ActiveRecord:: ...@@ -7,7 +7,7 @@ class RemoveLastVerificationFailedColumnsFromGeoProjectRegistry < ActiveRecord::
end end
def down def down
add_column :project_registry, :last_repository_verification_failed, :boolean, default: false, null: false add_column :project_registry, :last_repository_verification_failed, :boolean, default: false, null: false # rubocop:disable Migration/AddColumn
add_column :project_registry, :last_wiki_verification_failed, :boolean, default: false, null: false add_column :project_registry, :last_wiki_verification_failed, :boolean, default: false, null: false # rubocop:disable Migration/AddColumn
end end
end end
...@@ -7,7 +7,7 @@ class RemoveOldRepositoryVerificationChecksumFromGeoProjectRegistry < ActiveReco ...@@ -7,7 +7,7 @@ class RemoveOldRepositoryVerificationChecksumFromGeoProjectRegistry < ActiveReco
end end
def down def down
add_column :project_registry, :repository_verification_checksum, :string add_column :project_registry, :repository_verification_checksum, :string # rubocop:disable Migration/AddLimitToStringColumns
add_column :project_registry, :wiki_verification_checksum, :string add_column :project_registry, :wiki_verification_checksum, :string # rubocop:disable Migration/AddLimitToStringColumns
end end
end end
...@@ -3,15 +3,17 @@ module RuboCop ...@@ -3,15 +3,17 @@ module RuboCop
module MigrationHelpers module MigrationHelpers
# Returns true if the given node originated from the db/migrate directory. # Returns true if the given node originated from the db/migrate directory.
def in_migration?(node) def in_migration?(node)
dirname = File.dirname(node.location.expression.source_buffer.name) dirname(node).end_with?('db/migrate', 'db/geo/migrate') || in_post_deployment_migration?(node)
dirname.end_with?('db/migrate', 'db/post_migrate')
end end
def in_post_deployment_migration?(node) def in_post_deployment_migration?(node)
dirname = File.dirname(node.location.expression.source_buffer.name) dirname(node).end_with?('db/post_migrate', 'db/geo/post_migrate')
end
private
dirname.end_with?('db/post_migrate') def dirname(node)
File.dirname(node.location.expression.source_buffer.name)
end end
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