-
Notifications
You must be signed in to change notification settings - Fork 89
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
Enhancement: update indexer table schema #1143
Conversation
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.
It looks like I messed up your PR by merging in ps://github.com//pull/1144 so you'll have conflicts.
@@ -3,7 +3,7 @@ | |||
-- TODO? replace all 'addr bytea' with 'addr_id bigint' and a mapping table? makes addrs an 8 byte int that fits in a register instead of a 32 byte string | |||
|
|||
CREATE TABLE IF NOT EXISTS block_header ( | |||
round bigint PRIMARY KEY, | |||
round numeric(20) PRIMARY KEY, |
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.
What is the rationale behind choosing 20 as opposed to another number?
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.
this is because uint64 max is 18446744073709551615 and it's a value of 20 digits.
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.
Got it thanks!
require.NoError(t, err) | ||
|
||
migrationState, err = db.getMigrationState(context.Background(), nil) | ||
require.NoError(t, err) | ||
|
||
assert.Equal(t, types.MigrationState{NextMigration: 6}, migrationState) | ||
} | ||
|
||
func TestConvertBigIntType(t *testing.T) { |
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.
Not sure if this is necessary, but should we add a test case that asserts the existing values aren't changed by the type conversion?
i.e. insert round 1,000,000 convert the type and assert that the round is still 1,000,000?
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.
good point. I think this can be covered by running the block validator.
Codecov Report
@@ Coverage Diff @@
## develop #1143 +/- ##
===========================================
+ Coverage 60.07% 60.29% +0.21%
===========================================
Files 52 52
Lines 8752 8764 +12
===========================================
+ Hits 5258 5284 +26
+ Misses 3012 2994 -18
- Partials 482 486 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. |
@@ -0,0 +1,123 @@ | |||
package schema |
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.
Is there a way we can name this file test
something or otherwise mark the fact that it's not the actual current production schema?
It doesn't seem like we're maintaining old versions of the schema for past updates. What was our process for previous updates regarding schema testing?
this PR is replaced by #1166 |
Summary
This PR updates the schema for db tables to use numeric(20) type for columns that could have values larger than bigint type.
Test Plan
Add a unit test for the migration, run indexer daemon to check migration happened, and check db to validate that table schema has been updated.