Skip to content

Conversation

nvasilevski
Copy link
Contributor

We would like to make .rb schema dumps as database-agnostic as possible.

This PR proposes default high precision timestamp functions for datetime columns to be dumped as high_precision_current_timestamp abstraction.

Since schema is loaded in a context of an adapter lambda with high_precision_timestamp_function call in it resolves to adapter-specific high precision timestamp function

@nvasilevski nvasilevski force-pushed the abstract-high-precision-timestamp-function-in-schema-dump branch 6 times, most recently from 14a833e to bdae13d Compare February 10, 2025 23:57
@nvasilevski nvasilevski force-pushed the abstract-high-precision-timestamp-function-in-schema-dump branch from bdae13d to 8563ff1 Compare February 11, 2025 00:07
@matthewd
Copy link
Member

I see that that is currently a public/documented method, but I'm not sure it should be... it feels like implementation detail that [up to now] is only expected to be of interest to adapter implementers.

I'm also generally not super keen on emphasizing the fact that a -> { .. } default block can contain arbitrary code, given how that might lead people to misunderstanding when it gets called, etc.

Given those, if we're going to special-case it, I think I feel like a default: :now sort of spelling would be clearer?

Otherwise we're basically obliged to document the full -> { high_precision_current_timestamp } spelling anyway: detecting that people have used that exact expression is only really helpful if we're also guiding people to do so.

The schema dump needs to be able to load again (obviously 😄), but I feel it's equally important that it reads to a user as being a [flattened] restatement of their migrations... so best to avoid introducing things that may not feel like a person would write it that way, at least where feasible.

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.

2 participants