diff --git a/aggregator_core/src/datastore.rs b/aggregator_core/src/datastore.rs index 844921e1d..1aa6e8ba4 100644 --- a/aggregator_core/src/datastore.rs +++ b/aggregator_core/src/datastore.rs @@ -102,7 +102,7 @@ macro_rules! supported_schema_versions { // version is seen, [`Datastore::new`] fails. // // Note that the latest supported version must be first in the list. -supported_schema_versions!(6, 5); +supported_schema_versions!(7, 6); /// Datastore represents a datastore for Janus, with support for transactional reads and writes. /// In practice, Datastore instances are currently backed by a PostgreSQL database. diff --git a/db/00000000000007_task_aggregation_counters.down.sql b/db/00000000000007_task_aggregation_counters.down.sql new file mode 100644 index 000000000..fe38e502c --- /dev/null +++ b/db/00000000000007_task_aggregation_counters.down.sql @@ -0,0 +1 @@ +DROP TABLE task_aggregation_counters; diff --git a/db/00000000000007_task_aggregation_counters.up.sql b/db/00000000000007_task_aggregation_counters.up.sql new file mode 100644 index 000000000..cb38bda2f --- /dev/null +++ b/db/00000000000007_task_aggregation_counters.up.sql @@ -0,0 +1,14 @@ +-- Per-task report aggregation counters, used for metrics. +-- +-- Fillfactor is lowered to improve the likelihood of heap-only tuple optimizations. See the +-- discussion around this setting for the task_upload_counters table. +CREATE TABLE task_aggregation_counters( + id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, -- artificial ID, internal only + task_id BIGINT NOT NULL, -- task ID the counter is associated with + ord BIGINT NOT NULL, -- the ordinal index of the task aggregation counter + + success BIGINT NOT NULL DEFAULT 0, -- reports successfully aggregated + + CONSTRAINT task_aggregation_counters_unique_id UNIQUE(task_id, ord), + CONSTRAINT fk_task_id FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE +) WITH (fillfactor = 50);