d8be981466
add_column_with_default is implemented in terms of update_column_in_batches, but update_column_in_batches can be used independently. Neither of these should be used on the specified large tables, because they will cause issues on large instances like GitLab.com. This also ignores the cop for all existing migrations, renaming AddColumnWithDefaultToLargeTable where appropriate.
22 lines
606 B
Ruby
22 lines
606 B
Ruby
# rubocop:disable Migration/UpdateLargeTable
|
|
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
|
|
# for more information on how to write migrations for GitLab.
|
|
|
|
class MigrateUserProjectView < ActiveRecord::Migration
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
# Set this constant to true if this migration requires downtime.
|
|
DOWNTIME = false
|
|
|
|
disable_ddl_transaction!
|
|
|
|
def up
|
|
update_column_in_batches(:users, :project_view, 2) do |table, query|
|
|
query.where(table[:project_view].eq(0))
|
|
end
|
|
end
|
|
|
|
def down
|
|
# Nothing can be done to restore old values
|
|
end
|
|
end
|