Changeset 0.17.0 (#75)
This commit is contained in:
42
server/database/migrations/002_v017_persona_kb.sql
Normal file
42
server/database/migrations/002_v017_persona_kb.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
-- v0.17.0: Persona-KB Binding + Enterprise KB Mode
|
||||
--
|
||||
-- New: persona_knowledge_bases join table
|
||||
-- New: knowledge_bases.discoverable column
|
||||
-- New: kb_direct_access platform policy
|
||||
|
||||
-- =========================================
|
||||
-- 1. Persona-KB Binding
|
||||
-- =========================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS persona_knowledge_bases (
|
||||
persona_id UUID NOT NULL REFERENCES personas(id) ON DELETE CASCADE,
|
||||
kb_id UUID NOT NULL REFERENCES knowledge_bases(id) ON DELETE CASCADE,
|
||||
auto_search BOOLEAN NOT NULL DEFAULT false,
|
||||
added_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (persona_id, kb_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_persona_kb_persona ON persona_knowledge_bases(persona_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_persona_kb_kb ON persona_knowledge_bases(kb_id);
|
||||
|
||||
COMMENT ON TABLE persona_knowledge_bases IS 'Binds KBs to Personas — the Persona becomes a gateway to its KBs';
|
||||
COMMENT ON COLUMN persona_knowledge_bases.auto_search IS 'true = auto-prepend top-K results to context; false = kb_search tool only';
|
||||
|
||||
-- =========================================
|
||||
-- 2. Enterprise KB Mode
|
||||
-- =========================================
|
||||
|
||||
ALTER TABLE knowledge_bases
|
||||
ADD COLUMN IF NOT EXISTS discoverable BOOLEAN NOT NULL DEFAULT true;
|
||||
|
||||
COMMENT ON COLUMN knowledge_bases.discoverable IS 'false = hidden from user KB lists, only accessible through Persona binding';
|
||||
|
||||
-- =========================================
|
||||
-- 3. Platform Policy
|
||||
-- =========================================
|
||||
|
||||
INSERT INTO platform_policies (key, value) VALUES
|
||||
('kb_direct_access', 'true')
|
||||
ON CONFLICT (key) DO NOTHING;
|
||||
|
||||
COMMENT ON COLUMN platform_policies.key IS 'kb_direct_access: when false, disables channel KB popup (strict enterprise mode)';
|
||||
Reference in New Issue
Block a user