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 default_timezone to vary between databases #43831

Merged
merged 3 commits into from
Dec 13, 2021

Conversation

matthewd
Copy link
Member

@matthewd matthewd commented Dec 10, 2021

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 or local. (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.

@matthewd matthewd force-pushed the connection-timezone branch 2 times, most recently from fcebb9c to f1b526b Compare December 10, 2021 13:05
Now that multiple databases are more commonly supported, it seems less
reasonable to assume they all agree on stored timezone. Ultimately we
might need to further accomodate differing definitions of "local", but
this is a start.
We previously relied upon definition order to prevent this, but now
we're defining these types in a child TypeMap, so that won't work.

The loose patterns we define here seem like they'd be in general danger
of this sort of issue, but for now we can just address the immediately
affected ones.
@matthewd matthewd merged commit 85f4535 into rails:main Dec 13, 2021
@matthewd matthewd deleted the connection-timezone branch December 13, 2021 12:29
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