Add a rubocop cop that fails if a migration uses a table from TABLES_TO_BE_RENAMED
A rename table helper was introduced on !54354 (merged) that allows renaming tables without downtime.
The process relies on two migrations: A regular migration executed in a release N.M
that does the rename and a post-migration executed in a release N.M+1
that finalizes the rename.
During those releases, the table that got renamed cannot be modified, if it's the migration can fail, more details on !54354 (comment 561981489). To prevent this, some manual steps were added to the rename process https://gitlab.com/gitlab-org/gitlab/-/blob/f2c21f17ec85d91c60115d3ee5e2dee628e8e552/doc/development/database/rename_database_tables.md#L87-91. However, it'd be great to have some automation around this
Proposal
From !54354 (comment 565871519)
Rubocop:
- Read the
TABLES_TO_BE_RENAMED
constant and for each table: - Find the latest rename migration and the finalize rename migrations. (we know the timestamps -> time period where things can break)
- Collect all migrations and post migrations for the this period.
- Inspect them and try to find table modification method calls.