Skip to content

Programmatically document column ignores

Andreas Brandl requested to merge ab/ignorable-columns into master

What does this MR do?

Add a IgnorableColumns concern to help us with documenting column ignores. This requires us to add a date and release of when we can remove the column-ignore the earliest. This should be useful for us to reason better about this and it'd also allow us to run automated analysis which column-ignores can be removed (see rake db:obsolete_ignored_columns, for example).

In more detail, this MR does the following:

  • Define IgnorableColumns concern
  • Enforce its usage with rubocop, discourage usage of adding to ignored_columns += ...
  • Adjust rake task db:obsolete_ignored_columns to consider removal information given (the removal_after date).

Issue: #33127 (closed)

Example for new column ignore method:

class MyModel < ...
  ignore_column :id, remove_after: '2019-11-17', remove_with: '12.6'
end

The ignore_column call can be removed after the date given and best with the release indicated.

A rake db:obsolete_ignored_columns now yields this output, if

  1. the column has been dropped
  2. the remove_after date has passed.
The following `ignored_columns` are obsolete and can be removed:
Project:
 - foo                            Remove after 2019-11-01 with 12.6

WARNING: Removing columns is tricky because running GitLab processes may still be using the columns.

See also https://docs.gitlab.com/ee/development/what_requires_downtime.html#dropping-columns
Edited by 🤖 GitLab Bot 🤖

Merge request reports