nidus-sync/migrations/00014_h3_aggregation.sql
Eli Ribble e48abb09c0
Go to h3 v4, Add initial h3 aggregation work
This calculates the summary information of data in h3 nodes and puts it
in the database for fast lookup.
2025-11-13 23:49:12 +00:00

20 lines
520 B
SQL

-- +goose Up
-- CREATE EXTENSION h3;
-- CREATE EXTENSION h3_postgis CASCADE;
CREATE TYPE H3AggregationType AS ENUM (
'MosquitoSource',
'ServiceRequest');
CREATE TABLE h3_aggregation (
id SERIAL PRIMARY KEY,
cell h3index NOT NULL,
resolution INT NOT NULL,
count_ INTEGER NOT NULL,
type_ H3AggregationType NOT NULL,
organization_id INTEGER REFERENCES organization (id) NOT NULL,
UNIQUE(cell, organization_id, type_));
-- +goose Down
DROP TABLE h3_aggregation;
DROP TYPE H3AggregationType;
-- DROP EXTENSION h3;