Skip to content
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

Open
wants to merge 6 commits into
base: staging
Choose a base branch
from

Conversation

Gslaughl
Copy link
Contributor

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.

VALUES (diff_ilk_identifier,
new_diff.block_number,
new_diff.rate,
ilk_art_before_block(new_diff.ilk_id, new_diff.block_number),
Copy link
Contributor Author

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.

@Gslaughl Gslaughl force-pushed the vdb-940-ilk-history-table branch from 4097110 to f020017 Compare November 1, 2019 13:33


-- +goose StatementBegin
CREATE OR REPLACE FUNCTION maker.update_time_created() RETURNS TRIGGER
Copy link
Contributor Author

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant