Use model timestamps when available #18
Merged
+139
−6
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.
It changes how the value for
created_at
column inirontrail_changes
rows is determined. Originally, it was just set to whatever postgres'sNOW()
function would return. This changes it so that it considers the models' timestamp attributes (created_at
andupdated_at
). Note: it doesn't account for*_on
or other name variations for timestamps.The logic is the following:
created_at
column. Otherwise*, it uses the value ofNOW()
.updated_at
column. Otherwise*, it uses the value ofNOW()
.NOW()
.Related tasks:
This is an alternative to #17 -- there could be a hybrid of both, but I feel for now let's take the simpler route of this PR only. The only "odd" case is that it would be harder to determine the creation date of
irontrail_changes
records in a test environment, since there's no way to mock it. But I understand that the way it is covers most uses cases with less overall complexity, while still preserving a predictable and good behavior in production environments.