nidus-sync/db/migrations/00022_h3cell_fieldseeker_tables.sql
Eli Ribble b542b8268e Add precalc h3 cells to fieldseeker tables
This makes it so we don't have to try to parse the geometry JSON and
instead can just pass pre-calculated h3 values, which take fewer bytes,
everywhere.
2026-01-05 23:25:16 +00:00

11 lines
757 B
SQL

-- +goose Up
ALTER TABLE fieldseeker.pointlocation ADD COLUMN h3cell h3index GENERATED ALWAYS AS (h3_latlng_to_cell(geospatial, 15)) STORED;
ALTER TABLE fieldseeker.servicerequest ADD COLUMN h3cell h3index GENERATED ALWAYS AS (h3_latlng_to_cell(geospatial, 15)) STORED;
ALTER TABLE fieldseeker.trapdata ADD COLUMN h3cell h3index GENERATED ALWAYS AS (h3_latlng_to_cell(geospatial, 15)) STORED;
ALTER TABLE fieldseeker.treatment ADD COLUMN h3cell h3index GENERATED ALWAYS AS (h3_latlng_to_cell(geospatial, 15)) STORED;
-- +goose Down
ALTER TABLE fieldseeker.pointlocation DROP COLUMN h3cell;
ALTER TABLE fieldseeker.servicerequest DROP COLUMN h3cell;
ALTER TABLE fieldseeker.trapdata DROP COLUMN h3cell;
ALTER TABLE fieldseeker.treatment DROP COLUMN h3cell;