-
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
feat: add v1 schema #528
feat: add v1 schema #528
Conversation
Codecov Report
@@ Coverage Diff @@
## master #528 +/- ##
========================================
- Coverage 42.1% 40.6% -1.6%
========================================
Files 40 40
Lines 3100 3237 +137
========================================
+ Hits 1308 1315 +7
- Misses 1583 1713 +130
Partials 209 209 |
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.
still reviewing, adding a comment while I remember.
model/actors/reward/chainreward.go
Outdated
NewRewardSmoothedPositionEstimate string `pg:"type:numeric,notnull"` | ||
NewRewardSmoothedVelocityEstimate string `pg:"type:numeric,notnull"` | ||
TotalMinedReward string `pg:"type:numeric,notnull"` | ||
NewReward string `pg:"type:numeric,use_zero"` |
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 should be notnull
instead of use_zero
, since its a string
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.
fixed
Can we allow a configurable single schema name to use? When we load the backfill it should preferably go into the |
See this commit d6273b1 |
@@ -42,5 +77,16 @@ func (ml MinerFeeDebtList) Persist(ctx context.Context, s model.StorageBatch, ve | |||
if len(ml) == 0 { | |||
return nil | |||
} | |||
|
|||
if version.Major != 1 { | |||
// Support older versions, but in a non-optimal way |
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 something like this worth logging? (Here and elsewhere in the persist methods)
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 could be a really noisy log messages since it would fire on every write. I'll look at issuing a warning when visor starts
storage/migrate.go
Outdated
if target.Major != dbVersion.Major { | ||
// Version 0.0 indicates that the database has not been initialised with a schema yet | ||
if target.Major != dbVersion.Major && | ||
!(dbVersion.Major == 0 && dbVersion.Patch == 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.
nit: if this check is performed elsewhere dbVersion.IsInitalized()
would be a bit cleaner.
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 rewrote this area to check explicitly whether the version tables are initialized or not
Added |
Added internal message tables as per #482 (comment) |
model/messages/internal.go
Outdated
From string `pg:",notnull"` | ||
To string `pg:",notnull"` | ||
Value string `pg:"type:numeric,notnull"` | ||
Method uint64 `pg:",use_zero"` |
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.
should be of type string based on comment here: #482 (comment)
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 catch, will fix
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.
Yep, let's do it as a follow-up
6452539
to
32306a9
Compare
* feat: enable models to be version aware * Use a structured version * Move schema migrations to new versioned package * Add base SQL for schemas and update README * Fix some spelling errors caught by lint * Appease the lint god * Incorporate pr review feedback Create v1 schema and adjust hypertable parameters Use numeric type to represent numbers add integer now function to each hypertable multisig tx param field is nullable Add Height to IDAddress and ChainEconomics Fix ups to ensure schema v1 matches models Some lint fixes Ensure older schema version can be installed in new database Add add FilReserveDisbursed for chain economics Support backwards compatibility with v0 models Fix genesis test Support custom postgresql schema names Explicitly check whether database has initialized version tables Fix ChainReward.NewReward to be notnull Convert value column in parsed_messages to numeric Add actor_family colum to derived_gas_outputs Add internal_messages and internal_parsed_messages models Make InternalParsedMessage.Method a string to match schema Remove extension comment Only set base schema search path if non-default Fix typo Add version number to initial version tables Fix template typo Revert adding version number to initial version tables Remove extension creation Remove owner statements from v1 schema Use fixed statediff Use merged version in statediff repo tweak logger name
Consolidate all v0 migrations into a new v1 schema with some improvements. Visor supports both v0 and v1 schemas when writing directly to database so this won't block feature updates while we migrate to the newer schema. CSV output uses the latest schema.
Incorporates the following PRs:
height
to tables without height #484)Also:
NOTE: I did look at changing the schema name to
visor
(for #218) but it turned out to be a much larger and more invasive change than I wanted, especially since I am trying to give us a period of compatibility to allow us to migrate between v0 and v1 of the schema. Go-pg has no explicit support for different schemas (workaround here) and there are some rough edges when using some of the timescale functions such asset_integer_now_func
(which needs the schema embedded in the name of the table passed to it)Summary of Schema Changes
Added a new function
current_height
which returns the expected current epoch. All hypertables have been set to usecurrent_height
as their "now" function.The following tables are no longer hypertables due to low rates of growth:
The following tables have been converted to hypertables:
The following tables have had their hypertable chunking adjusted:
The following tables have additional columns:
The following tables have had columns changed to use numeric data type:
New tables: