rails_admin
https://github.com/railsadminteam/rails_admin
Ruby
RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
Gitlab::Database::MigrationHelpers#update_column_in_batches
Updates the value of a column in batches.
This method updates the table in batches of 5% of the total row count.
This method will continue updating rows until no rows remain.
When given a block this method will yield two values to the block:
1. An instance of `Arel::Table` for the table that is being updated.
2. The query to run as an Arel object.
By supplying a block one can add extra conditions to the queries being
executed. Note that the same block is used for _all_ queries.
Example:
update_column_in_batches(:projects, :foo, 10) do |table, query|
query.where(table[:some_column].eq('hello'))
end
This would result in this method updating only rows where
`projects.some_column` equals "hello".
table - The name of the table.
column - The name of the column to update.
value - The value for the column.
The `value` argument is typically a literal. To perform a computed
update, an Arel literal can be used instead:
update_value = Arel.sql('bar * baz')
update_column_in_batches(:projects, :foo, update_value) do |table, query|
query.where(table[:some_column].eq('hello'))
end
Rubocop's Metrics/AbcSize metric is disabled for this method as Rubocop
determines this method to be too complex while there's no way to make it
less "complex" without introducing extra methods (which actually will
make things _more_ complex).
rubocop: disable Metrics/AbcSizeEdit
git clone [email protected]:railsadminteam/rails_admin.git
cd rails_admin
open
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Gitlab--Database--MigrationHelpers-update_column_in_batches-for-pr
# Commit to gitgit add git commit -m "better docs for Gitlab::Database::MigrationHelpers#update_column_in_batches"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Gitlab--Database--MigrationHelpers-update_column_in_batches-for-pr
hub pull-request
# Celebrate!