Add migration validator to make sure ignore_column is present in model

What does this MR do and why?

This MR adds a new validation to the migration schema validator. The new validator only checks migrations introduced in the MR. It validates that the associated model has the ignore_column(s) for the removed columns or the pipeline fails.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. Commit one or more post deploy migrations to remove columns
  2. Run the validation script

pipeline failure example: https://gitlab.com/gitlab-org/gitlab/-/jobs/8821888519#L199

❯ RAILS_ENV=development scripts/validate_migration_schema
$ git merge-base master HEAD
a4646cff84dd0eefe9c3c602464d7d65c640a4cd

$ git diff --name-only --diff-filter=A a4646cff84dd0eefe9c3c602464d7d65c640a4cd -- db/migrate db/post_migrate
db/post_migrate/20250108141455_remove_column_from_table.rb
db/post_migrate/20250109154838_remove_more_columns_test.rb

Error: Column operations, like dropping, renaming or primary key conversion, require columns to be ignored in
the model. This step is necessary because Rails caches the columns and re-uses it in various places across the
application. Refer to these pages for more information:

https://docs.gitlab.com/ee/development/database/avoiding_downtime_in_migrations.html#dropping-columns
https://docs.gitlab.com/ee/development/database/avoiding_downtime_in_migrations.html#renaming-columns
https://docs.gitlab.com/ee/development/database/avoiding_downtime_in_migrations.html#migrating-integer-primary-keys-to-bigint

Please ensure that columns are properly ignored in the models

ApplicationSetting: elasticsearch_aws, elasticsearch_search
Search::Zoekt::Index: metadata
Search::Zoekt::Node: metadata
Edited by Terri Chu

Merge request reports

Loading
Loading