new-column-with-volatile-default (US031)#
Automatic fix is not available.
What it does#
Checks new column with volatile default.
Why not?#
Adding a new column with a volatile default to an already populated table will have to backfill the newly added column with the default, causing the table to be locked and rewritten, in which no other operations can be performed on the table for the duration of the rewrite. This will cause downtime if the table is concurrently being accessed by other clients.
When should you?#
If the table is empty. If the table is not empty but is not being concurrently accessed.
Use instead:#
- Create the new column, nullable and without the volatile default.
- Set the default value for the newly created column.
- Backfill the newly created column for all existing rows.