Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More restore original db config in db rake tasks #51862

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

justinko
Copy link
Contributor

@justinko justinko commented May 19, 2024

Fixes #51830

Motivation / Background

This is just additional changes that would've been included in #46270

Detail

When running multiple db rake tasks in a single command, we should restore to the original "db config" in between each task.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@justinko
Copy link
Contributor Author

Working on test failures. Next time I'll run more tests before opening a pull.

end

def with_stubbed_temporary_connection(&block)
ActiveRecord::Tasks::DatabaseTasks.stub(:with_temporary_connection, ->(*, &block) { block.call }, &block)
Copy link
Contributor Author

@justinko justinko May 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just passes through with no asserting -- didn't think it was important since the logic doesn't pertain to it.

I did build a version with some asserting (the configs are passed to it) so if that's what we want ... I can swap it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rails 7.1 changes established database connection after calling rails db:test:prepare for multi-database apps
2 participants