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#add_column_with_default

Adds a column with a default value without locking an entire table.

This method runs the following steps:

1. Add the column with a default value of NULL.
2. Change the default value of the column to the specified value.
3. Update all existing rows in batches.
4. Set a `NOT NULL` constraint on the column if desired (the default).

These steps ensure a column can be added to a large and commonly used
table without locking the entire table for the duration of the table
modification.

table - The name of the table to update.
column - The name of the column to add.
type - The column type (e.g. `:integer`).
default - The default value for the column.
limit - Sets a column limit. For example, for :integer, the default is
        4-bytes. Set `limit: 8` to allow 8-byte integers.
allow_null - When set to `true` the column will allow NULL values, the
             default is to not allow NULL values.

This method can also take a block which is passed directly to the
`update_column_in_batches` method.

Source | Google | Stack overflow

Edit

git clone [email protected]:railsadminteam/rails_admin.git

cd rails_admin

open

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Gitlab--Database--MigrationHelpers-add_column_with_default-for-pr


# Commit to git

git add git commit -m "better docs for Gitlab::Database::MigrationHelpers#add_column_with_default"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Gitlab--Database--MigrationHelpers-add_column_with_default-for-pr

hub pull-request


# Celebrate!