-- V7: Obstacle logs - setiap deteksi YOLO yang signifikan dicatat
CREATE TABLE IF NOT EXISTS obstacle_logs (
    id             BIGSERIAL        PRIMARY KEY,
    user_id        BIGINT           NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    label          VARCHAR(100)     NOT NULL,
    confidence     DOUBLE PRECISION NOT NULL,
    direction      VARCHAR(20)      NOT NULL,
    estimated_dist VARCHAR(50)      NOT NULL,
    lat            DOUBLE PRECISION,
    lng            DOUBLE PRECISION,
    created_at     TIMESTAMP        NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_obstacle_user_id    ON obstacle_logs(user_id);
CREATE INDEX IF NOT EXISTS idx_obstacle_created_at ON obstacle_logs(created_at DESC);
