-
Notifications
You must be signed in to change notification settings - Fork 1
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
(VB-940) Create ilk history trigger-table #250
base: staging
Are you sure you want to change the base?
Conversation
VALUES (diff_ilk_identifier, | ||
new_diff.block_number, | ||
new_diff.rate, | ||
ilk_art_before_block(new_diff.ilk_id, new_diff.block_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.
Using a similar strategy to our flip/flap/flop trigger-tables, where we insert the prior values of each field aside from the one being provided by the trigger.
4097110
to
f020017
Compare
|
||
|
||
-- +goose StatementBegin | ||
CREATE OR REPLACE FUNCTION maker.update_time_created() RETURNS TRIGGER |
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.
created
is a little simpler than the rest of the triggers-- we're not adding a new row for each Vat.init
, because there will already be a rate
diff in the same block, since Vat.init
modifies rate
.
Also, Vat.init
can only be called once per ilk, so created
should only be set one time. That's why we're only updating created
if it was previously NULL
(line 1267)
@@ -0,0 +1,1350 @@ | |||
-- +goose Up | |||
CREATE TABLE api.ilk_state_history |
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.
Worth mentioning that exposing this table via postgraphile results in a query called allIlkStateHistories
, which is a bad name imo (though nice automatic pluralization by postgraphile!). So I'm kind of leaning towards something like ilk_state_snapshot
or historical_ilk_state
, in order to get more idiomatic query names
This story populates a table with snapshots of all ilks at every block where they changed, and keeps the history correctly updated if diffs arrive out of order. This story does NOT include re-org safety.