grape
https://github.com/intridea/grape
Ruby
An opinionated framework for creating REST-like APIs in Ruby.
Gitlab::Database::MigrationHelpers#change_column_type_using_background_migration
Changes the column type of a table using a background migration.
Because this method uses a background migration it's more suitable for
large tables. For small tables it's better to use
`change_column_type_concurrently` since it can complete its work in a
much shorter amount of time and doesn't rely on Sidekiq.
Example usage:
class Issue < ActiveRecord::Base
self.table_name = 'issues'
include EachBatch
def self.to_migrate
where('closed_at IS NOT NULL')
end
end
change_column_type_using_background_migration(
Issue.to_migrate,
:closed_at,
:datetime_with_timezone
)
Reverting a migration like this is done exactly the same way, just with
a different type to migrate to (e.g. `:datetime` in the above example).
relation - An ActiveRecord relation to use for scheduling jobs and
figuring out what table we're modifying. This relation _must_
have the EachBatch module included.
column - The name of the column for which the type will be changed.
new_type - The new type of the column.
batch_size - The number of rows to schedule in a single background
migration.
interval - The time interval between every background migration.Edit
git clone [email protected]:intridea/grape.git
cd grape
open
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Gitlab--Database--MigrationHelpers-change_column_type_using_background_migration-for-pr
# Commit to gitgit add git commit -m "better docs for Gitlab::Database::MigrationHelpers#change_column_type_using_background_migration"
# 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-change_column_type_using_background_migration-for-pr
hub pull-request
# Celebrate!