Ensure schemas are up-to-date after migration tests complete
What does this MR do and why?
If a CI migration leaves the database behind the current database schema, we need to ensure that the schema is brought up-to-date after the migrations run to prevent other tests from starting from an inconsistent state.
This commit consolidates the database cleanup for multiple databases by ensuring:
-
After a migration context is complete, either recreate the databases (if the number of columns approaches the max) or migrate all the schemas back to the latest and drop all data from both databases.
-
After a migration example runs, delete any leftover data for that specific database.
Related MR: !100233 (merged)
Closes #377796 (closed)
How to set up and validate locally
Running these two test files in order doesn't fail anymore
bundle exec rspec spec/migrations/change_public_projects_cost_factor_spec.rb spec/lib/gitlab/background_migration/update_ci_pipeline_artifacts_unknown_locked_status_spec.rb
Also:
bundle exec rspec spec/migrations/20220606080509_fix_incorrect_job_artifacts_expire_at_spec.rb spec/lib/gitlab/background_migration/update_ci_pipeline_artifacts_unknown_locked_status_spec.rb
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.