-
Notifications
You must be signed in to change notification settings - Fork 46
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
Change created_at and deleted_at to transaction_from and transaction_to #38
Conversation
8a541e1
to
884c282
Compare
85d3495
to
59e4524
Compare
…d_datetime` in the past than `valid_from`.
Assign `transaction_from` to `created_at` when after create record.
DEPRECATION WARNING: Using `Range#include?` to check the inclusion of a value in a date time range is deprecated. It is recommended to use `Range#cover?` instead of `Range#include?` to check the inclusion of a value in a date time range. (called from block in scope_relation at /lib/activerecord-bitemporal/bitemporal.rb:547) PR: rails/rails#38186
cebb0f4
to
0d18569
Compare
…me value when created.` sort by `created_at` is broken.
|
||
# Assign only if defined created_at and deleted_at | ||
if has_column?(:created_at) | ||
self.transaction_from = self.created_at if changes.key?("created_at") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case (created_at
was changed), it seems valid_from
and transaction_from
is not the same values.
Is this valid records? Does this cause problems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, valid_from
and transaction_from
are not the same because they have different information.
And they are the same by default.
company = Company.create
pp company.created_at.iso8601(10)
# => "2020-11-04T08:18:03.1952580000Z"
pp company.transaction_from.iso8601(10)
# => "2020-11-04T08:18:03.1952580000Z"
pp company.valid_from.iso8601(10)
# => "2020-11-04T08:18:03.1952580000Z"
@@ -373,4 +564,48 @@ class EmployeeWithUniquness < Employee | |||
end | |||
end | |||
end | |||
|
|||
xdescribe "without created_at deleted_at" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Summary
Change name
created_at
anddeleted_at
columns totransaction_from
andtransaction_to
.Before
After
NOTE
created_at
deleted_at
is still supported.However, it will not be supported in the future.