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
Pipeline #83058845 passed with stages
in 55 minutes and 41 seconds
class CreateFileRegistry < ActiveRecord::Migration[4.2]
def change
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 :bytes
t.string :sha256
t.string :sha256 # rubocop:disable Migration/AddLimitToStringColumns
t.datetime :created_at, null: false
end
......
......@@ -10,6 +10,6 @@ class AddIndexToProjectIdOnProjectRegistry < ActiveRecord::Migration[4.2]
end
def down
remove_index :project_registry, :project_id
remove_concurrent_index :project_registry, :project_id
end
end
......@@ -2,7 +2,7 @@ class AddLastWikiSyncedAtToProjectRegistry < ActiveRecord::Migration[4.2]
DOWNTIME = false
def change
add_column :project_registry, :last_wiki_synced_at, :datetime
add_column :project_registry, :last_wiki_successful_sync_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 # rubocop:disable Migration/Datetime
end
end
......@@ -7,14 +7,14 @@ class AddRetryCountFieldsToRegistries < ActiveRecord::Migration[4.2]
def up
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_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, :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
# Indecies
......@@ -25,14 +25,14 @@ class AddRetryCountFieldsToRegistries < ActiveRecord::Migration[4.2]
def down
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_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, :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
end
end
......@@ -2,7 +2,7 @@ class AddLastSyncFailureToProjectRegistry < ActiveRecord::Migration[4.2]
DOWNTIME = false
def change
add_column :project_registry, :last_repository_sync_failure, :string
add_column :project_registry, :last_wiki_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 # rubocop:disable Migration/AddLimitToStringColumns
end
end
......@@ -5,14 +5,14 @@ class AddRepositoryVerificationToProjectRegistry < ActiveRecord::Migration[4.2]
DOWNTIME = false
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_failed, :boolean, null: false, default: false
add_column :project_registry, :last_repository_verification_failure, :string
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 # 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_failed, :boolean, null: false, default: false
add_column :project_registry, :last_wiki_verification_failure, :string
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 # rubocop:disable Migration/AddLimitToStringColumns
end
end
......@@ -7,7 +7,7 @@ class MigrateCiJobArtifactsToSeparateRegistry < ActiveRecord::Migration[4.2]
t.integer "artifact_id", unique: true
t.integer "retry_count"
t.boolean "success"
t.string "sha256"
t.string "sha256" # rubocop:disable Migration/AddLimitToStringColumns
end
Geo::TrackingBase.transaction do
......
......@@ -4,7 +4,7 @@ class AddChecksumMismatchFieldsToProjectRegistry < ActiveRecord::Migration[4.2]
DOWNTIME = false
def change
add_column :project_registry, :repository_checksum_mismatch, :boolean, null: false, default: false
add_column :project_registry, :wiki_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 # rubocop:disable Migration/AddColumn
end
end
......@@ -6,9 +6,9 @@ class AddContainerRepositoryRegistry < ActiveRecord::Migration[5.0]
def change
create_table :container_repository_registry, id: :serial, force: :cascade do |t|
t.integer :container_repository_id, null: false
t.string :state
t.string :state # rubocop:disable Migration/AddLimitToStringColumns
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 :last_synced_at
t.datetime :created_at, null: false
......
......@@ -4,7 +4,7 @@ class AddCreatedAtToEventLogStates < ActiveRecord::Migration[5.2]
DOWNTIME = false
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
execute('UPDATE event_log_states SET created_at = (
......
......@@ -7,7 +7,7 @@ class RemoveLastVerificationFailedColumnsFromGeoProjectRegistry < ActiveRecord::
end
def down
add_column :project_registry, :last_repository_verification_failed, :boolean, default: false, null: false
add_column :project_registry, :last_wiki_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 # rubocop:disable Migration/AddColumn
end
end
......@@ -7,7 +7,7 @@ class RemoveOldRepositoryVerificationChecksumFromGeoProjectRegistry < ActiveReco
end
def down
add_column :project_registry, :repository_verification_checksum, :string
add_column :project_registry, :wiki_verification_checksum, :string
add_column :project_registry, :repository_verification_checksum, :string # rubocop:disable Migration/AddLimitToStringColumns
add_column :project_registry, :wiki_verification_checksum, :string # rubocop:disable Migration/AddLimitToStringColumns
end
end
......@@ -3,15 +3,17 @@ module RuboCop
module MigrationHelpers
# Returns true if the given node originated from the db/migrate directory.
def in_migration?(node)
dirname = File.dirname(node.location.expression.source_buffer.name)
dirname.end_with?('db/migrate', 'db/post_migrate')
dirname(node).end_with?('db/migrate', 'db/geo/migrate') || in_post_deployment_migration?(node)
end
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
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