-- V10: SOS events
CREATE TABLE IF NOT EXISTS sos_events (
    id              BIGSERIAL    PRIMARY KEY,
    user_id         BIGINT       NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    trigger_type    VARCHAR(50)  NOT NULL DEFAULT 'MANUAL',
    lat             DOUBLE PRECISION,
    lng             DOUBLE PRECISION,
    status          VARCHAR(20)  NOT NULL DEFAULT 'TRIGGERED',
    acknowledged_at TIMESTAMP,
    created_at      TIMESTAMP    NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_sos_user_id    ON sos_events(user_id);
CREATE INDEX IF NOT EXISTS idx_sos_status     ON sos_events(status);
CREATE INDEX IF NOT EXISTS idx_sos_created_at ON sos_events(created_at DESC);
