-- =============================================================================
-- MIGRATION: knowledge_entries.links — tappable links a bot reply can carry
--
-- Part of the "advanced Q&A + live links" work: the widget can now render
-- e.g. a direct link to an order or policy page alongside the answer text,
-- not just prose. [{label, url}][], defaulting to an empty array so every
-- reader can iterate it unconditionally rather than null-checking.
--
-- Run: psql "$CHAT_DATABASE_URL" -f chat-service/prisma/migrations/manual/006_knowledge_entry_links.sql
-- =============================================================================

BEGIN;

ALTER TABLE "chat"."knowledge_entries"
  ADD COLUMN IF NOT EXISTS "links" JSONB NOT NULL DEFAULT '[]'::jsonb;

COMMIT;

-- Verify
SELECT column_name, data_type, column_default
FROM information_schema.columns
WHERE table_schema = 'chat' AND table_name = 'knowledge_entries' AND column_name = 'links';
