Allow default_timezone to vary between databases #43831
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Now that multiple databases are more commonly supported, it seems less reasonable to assume they all agree on stored timezone.
Instead, we can allow each database to be separately configured as to whether it stores datetimes in
utc
orlocal
. (This doesn't address the fact that databases might disagree about what "local" looks like -- but that seems like a more involved change, so let's take the easier step first.)We continue to respect
ActiveRecord.default_timezone
(including runtime changes to that value) if the connection has not been specifically configured. If it has, though, we use the configured value regardless of what the global setting contains.For context, my downstream motivation is to remove https://github.com/github/github-ds/blob/10d2c2618577f799887d6ca6571033e4d8d869c5/lib/github/sql.rb#L404, which achieves the same end by toggling the global setting at runtime.