-
Notifications
You must be signed in to change notification settings - Fork 122
staticaddr: migrate deposit swap hashes #988
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
Changes from all commits
35901d1
6e7441b
a1af860
d7ac314
d5e3075
fe7622d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ALTER TABLE deposits DROP COLUMN swap_hash; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ALTER TABLE deposits ADD swap_hash BLOB; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,3 +93,51 @@ SELECT EXISTS ( | |
| FROM static_address_swaps | ||
| WHERE swap_hash = $1 | ||
| ); | ||
|
|
||
| -- name: MapDepositToSwap :exec | ||
| UPDATE | ||
| deposits | ||
| SET | ||
| swap_hash = $2 | ||
| WHERE | ||
| deposit_id = $1; | ||
|
|
||
| -- name: SwapHashForDepositID :one | ||
| SELECT | ||
| swap_hash | ||
| FROM | ||
| deposits | ||
| WHERE | ||
| deposit_id = $1; | ||
|
|
||
| -- name: DepositIDsForSwapHash :many | ||
| SELECT | ||
| deposit_id | ||
| FROM | ||
| deposits | ||
| WHERE | ||
| swap_hash = $1; | ||
|
|
||
| -- name: DepositsForSwapHash :many | ||
| SELECT | ||
| d.*, | ||
| u.update_state, | ||
| u.update_timestamp | ||
| FROM | ||
| deposits d | ||
| LEFT JOIN | ||
| deposit_updates u ON u.id = ( | ||
| SELECT id | ||
| FROM deposit_updates | ||
| WHERE deposit_id = d.deposit_id | ||
| ORDER BY update_timestamp DESC | ||
| LIMIT 1 | ||
| ) | ||
| WHERE | ||
| d.swap_hash = $1; | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too many empty lines in this file. I propose to have 1 empty line between the queries.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 propose to try to use LATERAL JOIN. It should work faster than an embedded query.
Please make sure to have this index:
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.
LATERAL JOINis not supported by sqlite.