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

Allow schema_dump database config to be set via DATABASE_URL #50745

Closed

Conversation

mscoutermarsh
Copy link
Contributor

@mscoutermarsh mscoutermarsh commented Jan 13, 2024

In database.yml, schema_dump can currently be set to false, nil or a file path.

I found that if you configure your database via DATABASE_URL, the false value does not work because it comes through as a string.

This change allows ?schema_dump=false to disable the dump via database_url.

Additional information

Original PR for schema_dump #42804

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated 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.

@byroot
Copy link
Member

byroot commented Jan 14, 2024

Seems like a valuable thing to fix, but implementation wise I think it would make more sense to handle it in UrlConfig: https://github.com/rails/rails/blob/2835387192ff170f45fbeea9f5f821564d86f8b4/activerecord/lib/active_record/database_configurations/url_config.rb

@mscoutermarsh
Copy link
Contributor Author

Thank you @byroot. I'll revise

In `database.yml`, `schema_dump` can currently be set to `false`, `nil` or a file path.

I found that if you configure your database via DATABASE_URL, the false value does not work because it comes through as a string.

This change allows `?schema_dump=false` to disable the dump via database_url.
@mscoutermarsh
Copy link
Contributor Author

Pushed an update to handle it in UrlConfig.

casperisfine pushed a commit to Shopify/rails that referenced this pull request Jan 15, 2024
…figurable via `DATABASE_URL`

Fix: rails#50745

I went a bit farther and handled all the boolean configs, not just `schema_cache`.

Co-Authored-By: Mike Coutermarsh <coutermarsh.mike@gmail.com>
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.

None yet

2 participants