-- ============================================================
-- 027: 통합민감도 평가 테이블 생성
-- 계절별 민감도 평가 그리드 데이터 저장
-- properties 구조: { ID, FA_G, SM_G, SP_G, WT_G, MAX_G, GRID_LEVEL }
-- ============================================================

SET search_path TO wing, public;

CREATE EXTENSION IF NOT EXISTS postgis;

CREATE TABLE IF NOT EXISTS SENSITIVE_EVALUATION (
    SR_ID       BIGSERIAL       PRIMARY KEY,
    CATEGORY    VARCHAR(50)     NOT NULL DEFAULT '민감도평가',
    GEOM        public.geometry(Geometry, 4326) NOT NULL,
    PROPERTIES  JSONB           NOT NULL DEFAULT '{}',
    REG_DT      TIMESTAMP       NOT NULL DEFAULT CURRENT_TIMESTAMP,
    MOD_DT      TIMESTAMP
);

CREATE INDEX IF NOT EXISTS IDX_SE_GEOM ON SENSITIVE_EVALUATION USING GIST(GEOM);
CREATE INDEX IF NOT EXISTS IDX_SE_PROPERTIES ON SENSITIVE_EVALUATION USING GIN(PROPERTIES);

COMMENT ON TABLE  SENSITIVE_EVALUATION           IS '통합민감도 평가 그리드 테이블';
COMMENT ON COLUMN SENSITIVE_EVALUATION.SR_ID     IS '민감도 평가 ID';
COMMENT ON COLUMN SENSITIVE_EVALUATION.CATEGORY  IS '카테고리 (기본값: 민감도평가)';
COMMENT ON COLUMN SENSITIVE_EVALUATION.GEOM      IS '공간 데이터 (EPSG:4326)';
COMMENT ON COLUMN SENSITIVE_EVALUATION.PROPERTIES IS '계절별 민감도 값 { SP_G, SM_G, FA_G, WT_G, MAX_G, GRID_LEVEL }';
