generalbots/botserver/migrations/6.2.6-kb-groups/up.sql
Rodrigo Rodriguez (Pragmatismo) 037db5c381 feat: Major workspace reorganization and documentation update
- Add comprehensive documentation in botbook/ with 12 chapters
- Add botapp/ Tauri desktop application
- Add botdevice/ IoT device support
- Add botlib/ shared library crate
- Add botmodels/ Python ML models service
- Add botplugin/ browser extension
- Add botserver/ reorganized server code
- Add bottemplates/ bot templates
- Add bottest/ integration tests
- Add botui/ web UI server
- Add CI/CD workflows in .forgejo/workflows/
- Add AGENTS.md and PROD.md documentation
- Add dependency management scripts (DEPENDENCIES.sh/ps1)
- Remove legacy src/ structure and migrations
- Clean up temporary and backup files
2026-04-19 08:14:25 -03:00

19 lines
940 B
SQL

-- ============================================
-- KB Groups 2.0 - Access Control by RBAC Group
-- Version: 6.2.6
-- ============================================
-- Associates kb_collections with rbac_groups so that
-- THINK KB only returns results from KBs accessible to
-- the caller's groups. KBs with no associations remain public.
CREATE TABLE IF NOT EXISTS kb_group_associations (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
kb_id uuid NOT NULL REFERENCES kb_collections(id) ON DELETE CASCADE,
group_id uuid NOT NULL REFERENCES rbac_groups(id) ON DELETE CASCADE,
granted_by uuid REFERENCES users(id) ON DELETE SET NULL,
granted_at timestamptz NOT NULL DEFAULT NOW(),
UNIQUE (kb_id, group_id)
);
CREATE INDEX IF NOT EXISTS idx_kb_group_kb ON kb_group_associations(kb_id);
CREATE INDEX IF NOT EXISTS idx_kb_group_grp ON kb_group_associations(group_id);