Commit 5b9b5de8 authored by Mayra Cabrera's avatar Mayra Cabrera

Add a note about backporting columns with default

PostgreSQL 11 is required starting from 12.10. Before PostgreSQL 11,
adding a column requires a full table write, so if the table has a
considerable number of records, this causes for the table to be
unavailable until the column is added (which can take a while).

This commits adds a note on 'Add Column with Default' to state
backporting a column with default needs to use add_column_with_default,
and if a large table is involved, it should not add a default

Related to https://gitlab.com/gitlab-org/gitlab/-/issues/207820
parent d91a8d0e
......@@ -559,6 +559,11 @@ Before PostgreSQL 11, adding a column with a default was problematic as it would
have caused a full table rewrite. The corresponding helper `add_column_with_default`
has been deprecated and will be removed in a later release.
NOTE: **Note:**
If a backport adding a column with a default value is needed for %12.9 or earlier versions,
it should use `add_column_with_default` helper. If a [large table](https://gitlab.com/gitlab-org/gitlab/-/blob/master/rubocop/migration_helpers.rb#L12)
is involved, backporting to %12.9 is contraindicated.
## Changing the column default
One might think that changing a default column with `change_column_default` is an
......
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