-- AIS 선박 위치 이력 테이블
CREATE TABLE IF NOT EXISTS wing.AIS_TRACK (
  AIS_TRACK_SN  SERIAL PRIMARY KEY,
  MMSI          VARCHAR(12) NOT NULL,
  IMO           VARCHAR(12),
  VESSEL_NM     VARCHAR(100),
  VESSEL_TP     SMALLINT,
  LAT           NUMERIC(9,6),
  LON           NUMERIC(10,6),
  SPEED         NUMERIC(5,1),
  COURSE        NUMERIC(5,1),
  NAV_STATUS    SMALLINT,
  OBS_DTM       TIMESTAMPTZ NOT NULL,
  GEOM          GEOMETRY(Point, 4326),
  SRC_CD        VARCHAR(20) DEFAULT 'API'
);
CREATE INDEX IF NOT EXISTS idx_ais_track_mmsi ON wing.AIS_TRACK(MMSI);
CREATE INDEX IF NOT EXISTS idx_ais_track_obs_dtm ON wing.AIS_TRACK(OBS_DTM);
CREATE INDEX IF NOT EXISTS idx_ais_track_geom ON wing.AIS_TRACK USING GIST(GEOM);
