nidus-sync/db/migrations/00014_h3_aggregation.sql
Eli Ribble 41587c3694
Move database logic into separate subdirectory
I'm trying to see if this speeds up builds a bit. May not without a
module boundary, but for now it's nice organization to have as the
program grows.
2025-11-24 18:08:31 +00:00

21 lines
561 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,
count_ INTEGER NOT NULL,
geometry public.geometry(Polygon,4326),
organization_id INTEGER REFERENCES organization (id) NOT NULL,
resolution INT NOT NULL,
type_ H3AggregationType NOT NULL,
UNIQUE(cell, organization_id, type_));
-- +goose Down
DROP TABLE h3_aggregation;
DROP TYPE H3AggregationType;
-- DROP EXTENSION h3;