Skip to content

Deprecate add_column_with_default helper

Andreas Brandl requested to merge ab/add_column_with_default into master

What does this MR do?

This deprecates add_column_with_default helper, adds a cop to discourage its usage and updates docs. The helper method itself is now just delegating to add_column. This is possible without introducing inconsistencies because it yields the exact same result.

The background for this is that Postgres has seen a nice improvement in v11: It's now possible to add columns with a default value (and a not null constraint if desired) without rewriting the whole table. This makes it as quick as adding a column without a default.

Previously, add_column_with_default has been solved this with a few steps - adding column without a default, updating all records in batches, updating the column to set default and not null constraint.

In a later release (likely from %13.1), we might want to remove the helper method fully and change existing migrations to use add_column instead directly.

#207820 (closed)

Does this MR meet the acceptance criteria?

Conformity

Edited by 🤖 GitLab Bot 🤖

Merge request reports