Spaces:
Sleeping
Sleeping
File size: 1,753 Bytes
a6145bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | -- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- Green Guard v2 β Posts Geospatial & Metadata Migration
-- This fixes the 400 Bad Request error on the map feature.
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- 1. Add post_type for classification (normal, plantation, etc.)
ALTER TABLE posts ADD COLUMN IF NOT EXISTS post_type TEXT DEFAULT 'normal' CHECK (post_type IN ('normal', 'plantation'));
-- 2. Add latitude and longitude for precise positioning
ALTER TABLE posts ADD COLUMN IF NOT EXISTS latitude DOUBLE PRECISION;
ALTER TABLE posts ADD COLUMN IF NOT EXISTS longitude DOUBLE PRECISION;
-- 3. Add PostGIS geography column for spatial queries
ALTER TABLE posts ADD COLUMN IF NOT EXISTS location GEOGRAPHY(Point, 4326);
-- 4. Add human-readable address
ALTER TABLE posts ADD COLUMN IF NOT EXISTS address TEXT;
-- 5. Create spatial index for performance
CREATE INDEX IF NOT EXISTS idx_posts_location ON posts USING GIST (location);
CREATE INDEX IF NOT EXISTS idx_posts_post_type ON posts (post_type);
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- Note: Run this in the Supabase SQL Editor.
-- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|