|
| 1 | +-- +goose Up |
| 2 | + |
| 3 | +-- +goose StatementBegin |
| 4 | +ALTER TABLE _final_validator_dashboard_data_hourly |
| 5 | + COMMENT COLUMN epoch_start 'legacy column, used by ingestion. consumers of data should use the aliased variant instead', |
| 6 | + COMMENT COLUMN balance_start 'legacy column, used by ingestion. consumers of data should use the aliased variant instead', |
| 7 | + COMMENT COLUMN balance_min 'legacy column, used by ingestion. consumers of data should use the aliased variant instead', |
| 8 | + ADD COLUMN IF NOT EXISTS _is_backfill SimpleAggregateFunction(max, bool) DEFAULT 0 COMMENT 'if the row is part of a backfill insert', |
| 9 | + ADD COLUMN IF NOT EXISTS _botched_epoch_start_backfill_revision SimpleAggregateFunction(max, Int64) DEFAULT 0 COMMENT 'revision of the "botched epoch start" backfill. incrementing this will cause _staging_{epoch_start|balance_start|balance_min} to be replaced with whatever the _legacy columns are set to in the same row.', |
| 10 | + ADD COLUMN IF NOT EXISTS _staging_epoch_start AggregateFunction(minSimpleStateArgMax, Int64, Int64) Materialized initializeAggregation('minSimpleStateArgMaxState', epoch_start::Int64, _botched_epoch_start_backfill_revision::Int64), |
| 11 | + ADD COLUMN IF NOT EXISTS _staging_balance_start AggregateFunction(argMinMergeStateArgMax, AggregateFunction(argMin, Int64, Int64), SimpleAggregateFunction(max, Int64)) Materialized initializeAggregation('argMinMergeStateArgMaxState', balance_start, _botched_epoch_start_backfill_revision::Int64), |
| 12 | + ADD COLUMN IF NOT EXISTS _staging_balance_min AggregateFunction(minSimpleStateArgMax, Int64, Int64) Materialized initializeAggregation('minSimpleStateArgMaxState', balance_min::Int64, _botched_epoch_start_backfill_revision::Int64), |
| 13 | + -- the existing columns will be swapped out with the following aliases once the backfill is complete |
| 14 | + ADD COLUMN IF NOT EXISTS _public_epoch_start SimpleAggregateFunction(min, Int64) ALIAS finalizeAggregation(_staging_epoch_start), |
| 15 | + ADD COLUMN IF NOT EXISTS _public_balance_start AggregateFunction(argMin, Int64, Int64) ALIAS finalizeAggregation(_staging_balance_start), |
| 16 | + ADD COLUMN IF NOT EXISTS _public_balance_min SimpleAggregateFunction(min, Int64) ALIAS finalizeAggregation(_staging_balance_min) |
| 17 | +settings mutations_sync=2, alter_sync=1; |
| 18 | +-- +goose StatementEnd |
| 19 | +-- +goose StatementBegin |
| 20 | +ALTER TABLE _final_validator_dashboard_data_daily |
| 21 | + COMMENT COLUMN epoch_start 'legacy column, used by ingestion. consumers of data should use the aliased variant instead', |
| 22 | + COMMENT COLUMN balance_start 'legacy column, used by ingestion. consumers of data should use the aliased variant instead', |
| 23 | + COMMENT COLUMN balance_min 'legacy column, used by ingestion. consumers of data should use the aliased variant instead', |
| 24 | + ADD COLUMN IF NOT EXISTS _is_backfill SimpleAggregateFunction(max, bool) DEFAULT 0 COMMENT 'if the row is part of a backfill insert', |
| 25 | + ADD COLUMN IF NOT EXISTS _botched_epoch_start_backfill_revision SimpleAggregateFunction(max, Int64) DEFAULT 0 COMMENT 'revision of the "botched epoch start" backfill. incrementing this will cause _staging_{epoch_start|balance_start|balance_min} to be replaced with whatever the _legacy columns are set to in the same row.', |
| 26 | + ADD COLUMN IF NOT EXISTS _staging_epoch_start AggregateFunction(minSimpleStateArgMax, Int64, Int64) Materialized initializeAggregation('minSimpleStateArgMaxState', epoch_start::Int64, _botched_epoch_start_backfill_revision::Int64), |
| 27 | + ADD COLUMN IF NOT EXISTS _staging_balance_start AggregateFunction(argMinMergeStateArgMax, AggregateFunction(argMin, Int64, Int64), SimpleAggregateFunction(max, Int64)) Materialized initializeAggregation('argMinMergeStateArgMaxState', balance_start, _botched_epoch_start_backfill_revision::Int64), |
| 28 | + ADD COLUMN IF NOT EXISTS _staging_balance_min AggregateFunction(minSimpleStateArgMax, Int64, Int64) Materialized initializeAggregation('minSimpleStateArgMaxState', balance_min::Int64, _botched_epoch_start_backfill_revision::Int64), |
| 29 | + -- the existing columns will be swapped out with the following aliases once the backfill is complete |
| 30 | + ADD COLUMN IF NOT EXISTS _public_epoch_start SimpleAggregateFunction(min, Int64) ALIAS finalizeAggregation(_staging_epoch_start), |
| 31 | + ADD COLUMN IF NOT EXISTS _public_balance_start AggregateFunction(argMin, Int64, Int64) ALIAS finalizeAggregation(_staging_balance_start), |
| 32 | + ADD COLUMN IF NOT EXISTS _public_balance_min SimpleAggregateFunction(min, Int64) ALIAS finalizeAggregation(_staging_balance_min) |
| 33 | +settings mutations_sync=2, alter_sync=1; |
| 34 | +-- +goose StatementEnd |
| 35 | +-- +goose StatementBegin |
| 36 | +ALTER TABLE _final_validator_dashboard_data_weekly |
| 37 | + COMMENT COLUMN epoch_start 'legacy column, used by ingestion. consumers of data should use the aliased variant instead', |
| 38 | + COMMENT COLUMN balance_start 'legacy column, used by ingestion. consumers of data should use the aliased variant instead', |
| 39 | + COMMENT COLUMN balance_min 'legacy column, used by ingestion. consumers of data should use the aliased variant instead', |
| 40 | + ADD COLUMN IF NOT EXISTS _is_backfill SimpleAggregateFunction(max, bool) DEFAULT 0 COMMENT 'if the row is part of a backfill insert', |
| 41 | + ADD COLUMN IF NOT EXISTS _botched_epoch_start_backfill_revision SimpleAggregateFunction(max, Int64) DEFAULT 0 COMMENT 'revision of the "botched epoch start" backfill. incrementing this will cause _staging_{epoch_start|balance_start|balance_min} to be replaced with whatever the _legacy columns are set to in the same row.', |
| 42 | + ADD COLUMN IF NOT EXISTS _staging_epoch_start AggregateFunction(minSimpleStateArgMax, Int64, Int64) Materialized initializeAggregation('minSimpleStateArgMaxState', epoch_start::Int64, _botched_epoch_start_backfill_revision::Int64), |
| 43 | + ADD COLUMN IF NOT EXISTS _staging_balance_start AggregateFunction(argMinMergeStateArgMax, AggregateFunction(argMin, Int64, Int64), SimpleAggregateFunction(max, Int64)) Materialized initializeAggregation('argMinMergeStateArgMaxState', balance_start, _botched_epoch_start_backfill_revision::Int64), |
| 44 | + ADD COLUMN IF NOT EXISTS _staging_balance_min AggregateFunction(minSimpleStateArgMax, Int64, Int64) Materialized initializeAggregation('minSimpleStateArgMaxState', balance_min::Int64, _botched_epoch_start_backfill_revision::Int64), |
| 45 | + -- the existing columns will be swapped out with the following aliases once the backfill is complete |
| 46 | + ADD COLUMN IF NOT EXISTS _public_epoch_start SimpleAggregateFunction(min, Int64) ALIAS finalizeAggregation(_staging_epoch_start), |
| 47 | + ADD COLUMN IF NOT EXISTS _public_balance_start AggregateFunction(argMin, Int64, Int64) ALIAS finalizeAggregation(_staging_balance_start), |
| 48 | + ADD COLUMN IF NOT EXISTS _public_balance_min SimpleAggregateFunction(min, Int64) ALIAS finalizeAggregation(_staging_balance_min) |
| 49 | +settings mutations_sync=2, alter_sync=1; |
| 50 | +-- +goose StatementEnd |
| 51 | +-- +goose StatementBegin |
| 52 | +ALTER TABLE _final_validator_dashboard_data_monthly |
| 53 | + COMMENT COLUMN epoch_start 'legacy column, used by ingestion. consumers of data should use the aliased variant instead', |
| 54 | + COMMENT COLUMN balance_start 'legacy column, used by ingestion. consumers of data should use the aliased variant instead', |
| 55 | + COMMENT COLUMN balance_min 'legacy column, used by ingestion. consumers of data should use the aliased variant instead', |
| 56 | + ADD COLUMN IF NOT EXISTS _is_backfill SimpleAggregateFunction(max, bool) DEFAULT 0 COMMENT 'if the row is part of a backfill insert', |
| 57 | + ADD COLUMN IF NOT EXISTS _botched_epoch_start_backfill_revision SimpleAggregateFunction(max, Int64) DEFAULT 0 COMMENT 'revision of the "botched epoch start" backfill. incrementing this will cause _staging_{epoch_start|balance_start|balance_min} to be replaced with whatever the _legacy columns are set to in the same row.', |
| 58 | + ADD COLUMN IF NOT EXISTS _staging_epoch_start AggregateFunction(minSimpleStateArgMax, Int64, Int64) Materialized initializeAggregation('minSimpleStateArgMaxState', epoch_start::Int64, _botched_epoch_start_backfill_revision::Int64), |
| 59 | + ADD COLUMN IF NOT EXISTS _staging_balance_start AggregateFunction(argMinMergeStateArgMax, AggregateFunction(argMin, Int64, Int64), SimpleAggregateFunction(max, Int64)) Materialized initializeAggregation('argMinMergeStateArgMaxState', balance_start, _botched_epoch_start_backfill_revision::Int64), |
| 60 | + ADD COLUMN IF NOT EXISTS _staging_balance_min AggregateFunction(minSimpleStateArgMax, Int64, Int64) Materialized initializeAggregation('minSimpleStateArgMaxState', balance_min::Int64, _botched_epoch_start_backfill_revision::Int64), |
| 61 | + -- the existing columns will be swapped out with the following aliases once the backfill is complete |
| 62 | + ADD COLUMN IF NOT EXISTS _public_epoch_start SimpleAggregateFunction(min, Int64) ALIAS finalizeAggregation(_staging_epoch_start), |
| 63 | + ADD COLUMN IF NOT EXISTS _public_balance_start AggregateFunction(argMin, Int64, Int64) ALIAS finalizeAggregation(_staging_balance_start), |
| 64 | + ADD COLUMN IF NOT EXISTS _public_balance_min SimpleAggregateFunction(min, Int64) ALIAS finalizeAggregation(_staging_balance_min) |
| 65 | +settings mutations_sync=2, alter_sync=1; |
| 66 | +-- +goose StatementEnd |
| 67 | + |
| 68 | +-- +goose Down |
| 69 | +-- +goose StatementBegin |
| 70 | +ALTER TABLE _final_validator_dashboard_data_hourly |
| 71 | + DROP COLUMN IF EXISTS _is_backfill, |
| 72 | + DROP COLUMN IF EXISTS _botched_epoch_start_backfill_revision, |
| 73 | + DROP COLUMN IF EXISTS _staging_epoch_start, |
| 74 | + DROP COLUMN IF EXISTS _staging_balance_start, |
| 75 | + DROP COLUMN IF EXISTS _staging_balance_min, |
| 76 | + DROP COLUMN IF EXISTS _public_epoch_start, |
| 77 | + DROP COLUMN IF EXISTS _public_balance_start, |
| 78 | + DROP COLUMN IF EXISTS _public_balance_min |
| 79 | +settings mutations_sync=2, alter_sync=1; |
| 80 | +-- +goose StatementEnd |
| 81 | +-- +goose StatementBegin |
| 82 | +ALTER TABLE _final_validator_dashboard_data_daily |
| 83 | + DROP COLUMN IF EXISTS _is_backfill, |
| 84 | + DROP COLUMN IF EXISTS _botched_epoch_start_backfill_revision, |
| 85 | + DROP COLUMN IF EXISTS _staging_epoch_start, |
| 86 | + DROP COLUMN IF EXISTS _staging_balance_start, |
| 87 | + DROP COLUMN IF EXISTS _staging_balance_min, |
| 88 | + DROP COLUMN IF EXISTS _public_epoch_start, |
| 89 | + DROP COLUMN IF EXISTS _public_balance_start, |
| 90 | + DROP COLUMN IF EXISTS _public_balance_min |
| 91 | +settings mutations_sync=2, alter_sync=1; |
| 92 | +-- +goose StatementEnd |
| 93 | +-- +goose StatementBegin |
| 94 | +ALTER TABLE _final_validator_dashboard_data_weekly |
| 95 | + DROP COLUMN IF EXISTS _is_backfill, |
| 96 | + DROP COLUMN IF EXISTS _botched_epoch_start_backfill_revision, |
| 97 | + DROP COLUMN IF EXISTS _staging_epoch_start, |
| 98 | + DROP COLUMN IF EXISTS _staging_balance_start, |
| 99 | + DROP COLUMN IF EXISTS _staging_balance_min, |
| 100 | + DROP COLUMN IF EXISTS _public_epoch_start, |
| 101 | + DROP COLUMN IF EXISTS _public_balance_start, |
| 102 | + DROP COLUMN IF EXISTS _public_balance_min |
| 103 | +settings mutations_sync=2, alter_sync=1; |
| 104 | +-- +goose StatementEnd |
| 105 | +-- +goose StatementBegin |
| 106 | +ALTER TABLE _final_validator_dashboard_data_monthly |
| 107 | + DROP COLUMN IF EXISTS _is_backfill, |
| 108 | + DROP COLUMN IF EXISTS _botched_epoch_start_backfill_revision, |
| 109 | + DROP COLUMN IF EXISTS _staging_epoch_start, |
| 110 | + DROP COLUMN IF EXISTS _staging_balance_start, |
| 111 | + DROP COLUMN IF EXISTS _staging_balance_min, |
| 112 | + DROP COLUMN IF EXISTS _public_epoch_start, |
| 113 | + DROP COLUMN IF EXISTS _public_balance_start, |
| 114 | + DROP COLUMN IF EXISTS _public_balance_min |
| 115 | +settings mutations_sync=2, alter_sync=1; |
| 116 | +-- +goose StatementEnd |
0 commit comments