-- V12: AI configs - konfigurasi YOLO detection untuk setiap user (diatur Guardian)
CREATE TABLE IF NOT EXISTS ai_configs (
    id                    BIGSERIAL        PRIMARY KEY,
    guardian_id           BIGINT           REFERENCES users(id) ON DELETE SET NULL,
    user_id               BIGINT           NOT NULL UNIQUE REFERENCES users(id) ON DELETE CASCADE,
    confidence_threshold  DOUBLE PRECISION NOT NULL DEFAULT 0.5,
    alert_distance_close  DOUBLE PRECISION NOT NULL DEFAULT 1.5,
    alert_distance_medium DOUBLE PRECISION NOT NULL DEFAULT 3.0,
    max_inference_fps     INT              NOT NULL DEFAULT 5,
    enabled_labels        TEXT             NOT NULL DEFAULT 'ALL',
    updated_at            TIMESTAMP        NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_ai_config_user_id ON ai_configs(user_id);
