-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add unique_end_date
constraint to funding_rates
table
#2615
Conversation
What will happen if we get a duplicate entry. Is the error simply logged? |
Good question. An error would be logged, but it would also mean that any other rows in the batch would be ignored. I've updated the patch to fix this: https://github.com/get10101/10101/compare/fc36c9a54b22eeda84dccf463a872bc9c7b53543..23ac948ab64eda8cbe7a06abd343a0b62feb42f9. |
fc36c9a
to
23ac948
Compare
@@ -39,6 +39,8 @@ pub fn insert_funding_rates( | |||
|
|||
let affected_rows = diesel::insert_into(funding_rates::table) | |||
.values(funding_rates) | |||
.on_conflict(funding_rates::end_date) | |||
.do_nothing() | |||
.execute(conn)?; | |||
|
|||
if affected_rows == 0 { |
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.
🤔 Maybe we don't want this either?
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.
I agree, I've removed it now :D
23ac948
to
b9ddf11
Compare
We only need one funding rate entry per `end_date`. Without this change we were getting a new duplicate entry per maker restart. We `DO NOTHING` on conflict to ensure that the actually new rows in the batch will be inserted if we encounter any conflicts.
b9ddf11
to
d0e6b43
Compare
We only need one funding rate entry per
end_date
.Without this change we were getting a new duplicate entry per maker restart.