Commit 262bcdd6 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'update-background-migrations-docs' into 'master'

Updates background migration docs

See merge request gitlab-org/gitlab!21354
parents 19bf148a 5607c555
...@@ -16,10 +16,15 @@ migrations automatically reschedule themselves for a later point in time. ...@@ -16,10 +16,15 @@ migrations automatically reschedule themselves for a later point in time.
> the migrations. > the migrations.
In the vast majority of cases you will want to use a regular Rails migration In the vast majority of cases you will want to use a regular Rails migration
instead. Background migrations should _only_ be used when migrating _data_ in instead. Background migrations should be used when migrating _data_ in
tables that have so many rows this process would take hours when performed in a tables that have so many rows this process would take hours when performed in a
regular Rails migration. regular Rails migration.
Background migrations _may_ also be used when executing numerous single-row queries
for every item on a large dataset. Typically, for single-record patterns, runtime is
largely dependent on the size of the dataset, hence it should be split accordingly
and put into background migrations.
Background migrations _may not_ be used to perform schema migrations, they Background migrations _may not_ be used to perform schema migrations, they
should only be used for data migrations. should only be used for data migrations.
......
...@@ -103,10 +103,13 @@ and details for a database reviewer: ...@@ -103,10 +103,13 @@ and details for a database reviewer:
need to fit comfortably within `15s` - preferably much less than that - on GitLab.com. need to fit comfortably within `15s` - preferably much less than that - on GitLab.com.
- For column removals, make sure the column has been [ignored in a previous release](what_requires_downtime.md#dropping-columns) - For column removals, make sure the column has been [ignored in a previous release](what_requires_downtime.md#dropping-columns)
- Check [background migrations](background_migrations.md): - Check [background migrations](background_migrations.md):
- Establish a time estimate for execution on GitLab.com. - Establish a time estimate for execution on GitLab.com. For historical purposes,
- They should only be used when migrating data in larger tables. it's highly recommended to include this estimation on the merge request description.
- If a single `update` is below than `1s` the query can be placed - If a single `update` is below than `1s` the query can be placed
directly in a regular migration (inside `db/migrate`). directly in a regular migration (inside `db/migrate`).
- Background migrations are normally used, but not limited to:
- Migrating data in larger tables.
- Making numerous SQL queries per record in a dataset.
- Review queries (for example, make sure batch sizes are fine) - Review queries (for example, make sure batch sizes are fine)
- Because execution time can be longer than for a regular migration, - Because execution time can be longer than for a regular migration,
it's suggested to treat background migrations as post migrations: it's suggested to treat background migrations as post migrations:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment