gitlab-org--gitlab-foss/db/migrate/20170222143500_remove_old_project_id_columns.rb
Sean McGivern 1ab33b15d1 Add cop for use of remove_column
remove_column should only be used in the up (or change) step of a migration if
it's a post-deployment migration. Otherwise there will be downtime due to the
ActiveRecord column cache, which we can avoid by using the IgnorableColumn
concern in combination with a post-deployment migration.
2017-12-11 16:34:51 +00:00

30 lines
939 B
Ruby

# rubocop:disable Migration/RemoveColumn
# rubocop:disable RemoveIndex
class RemoveOldProjectIdColumns < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = true
DOWNTIME_REASON = 'Unused columns are being removed.'
def up
remove_index :ci_builds, :project_id if
index_exists?(:ci_builds, :project_id)
remove_column :ci_builds, :project_id
remove_column :ci_commits, :project_id
remove_column :ci_runner_projects, :project_id
remove_column :ci_triggers, :project_id
remove_column :ci_variables, :project_id
end
def down
add_column :ci_builds, :project_id, :integer
add_column :ci_commits, :project_id, :integer
add_column :ci_runner_projects, :project_id, :integer
add_column :ci_triggers, :project_id, :integer
add_column :ci_variables, :project_id, :integer
add_concurrent_index :ci_builds, :project_id
end
end