Fix fail-fast job when there are migrations present
What does this MR do and why?
!101613 (merged)
consolidated some of the logic for calling schema_migrate_down!
to
spec/support/multiple_databases.rb
, but it introduced some issues
with database cleanup. It appears calling
with_reestablished_active_record_base
disconnects connections and
clears attribute methods. We now need to:
- Ensure that tables are deleted before we migrate.
- Force a refresh of attribute methods after ensuring migrations are up.
Relates to #378582 (closed)
How to set up and validate locally
I've only reproduced this problem via containers:
docker network create test
docker run --network test --network-alias redis --name redis -d redis:6.0
docker run --network test -e POSTGRES_HOST_AUTH_METHOD=trust --name -d postgres postgres:12
docker run --network test -it registry.gitlab.com/gitlab-org/gitlab-build-images/debian-bullseye-ruby-2.7.patched-golang-1.18-node-16.14-postgresql-12:rubygems-3.2-git-2.36-lfs-2.9-chrome-103-yarn-1.22-graphicsmagick-1.3.36 bash
In the last image, follow the CI steps:
git clone --depth 1 https://gitlab.com/gitlab-org/gitlab.git
source scripts/utils.sh
source scripts/prepare_build.sh
source ./scripts/rspec_helpers.sh
scripts/gitaly-test-spawn
RAILS_ENV=test bin/rake db:reset && bin/rspec --fail-fast -Ispec -rspec_helper --color --format documentation --format RspecJunitFormatter --out rspec/junit_rspec.xml --tag ~quarantine spec/migrations/20210818185845_backfill_projects_with_coverage_spec.rb spec/db/migration_spec.rb
Test merge request: !101819 (closed) (fail-fast
actually succeeds now, but my hack causes a later script to fail)
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.
Edited by Stan Hu