Geojson DATA Operation change to Stable - Daniel C No.7

This commit is contained in:
sanghyeonhd
2025-11-28 16:07:42 +09:00
parent 2584e3fc53
commit 4cb41c92cd
5 changed files with 54 additions and 10 deletions

View File

@@ -4,11 +4,25 @@
-- 1. First ensure PostGIS is enabled
CREATE EXTENSION IF NOT EXISTS postgis;
-- 2. Clear existing data since it's in incorrect format (JTS serialized objects)
-- This data needs to be reprocessed anyway with the correct PostGIS approach
DELETE FROM public.tb_map_sheet_learn_data_geom;
-- 2. Check if column needs to be recreated (only if it's bytea type)
-- Only clear data if the column type is incorrect and needs conversion
DO $$
BEGIN
-- Only delete data if geom column exists and is bytea type
IF EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'tb_map_sheet_learn_data_geom'
AND column_name = 'geom'
AND data_type = 'bytea'
) THEN
DELETE FROM public.tb_map_sheet_learn_data_geom WHERE geom IS NOT NULL;
RAISE NOTICE 'Cleared incorrect bytea geometry data for conversion';
ELSE
RAISE NOTICE 'Geometry column is already correct type, skipping data deletion';
END IF;
END $$;
-- 3. Drop and recreate the geom column with correct PostGIS geometry type
-- 3. Drop and recreate the geom column with correct PostGIS geometry type (only if needed)
ALTER TABLE public.tb_map_sheet_learn_data_geom DROP COLUMN IF EXISTS geom;
ALTER TABLE public.tb_map_sheet_learn_data_geom ADD COLUMN geom geometry(Polygon, 5186);