Skip to content

πŸ—ƒοΈ build(database): add workspace_id indexes#15468

Merged
arvinxx merged 2 commits into
canaryfrom
lobe-9961-phase-3-migration-0108-add-workspace_id-btree-indexes-create
Jun 4, 2026
Merged

πŸ—ƒοΈ build(database): add workspace_id indexes#15468
arvinxx merged 2 commits into
canaryfrom
lobe-9961-phase-3-migration-0108-add-workspace_id-btree-indexes-create

Conversation

@arvinxx

@arvinxx arvinxx commented Jun 4, 2026

Copy link
Copy Markdown
Member

πŸ’» Change Type

  • πŸ‘· build

πŸ”— Related Issue

Related to LOBE-9961 (Phase 3 of the Workspace DB phased rollout, LOBE-9957). Follows #15465 (Phase 2, FK).

πŸ”€ Description of Change

Phase 3 / migration 0108 of the workspace DB rollout β€” adds indexes for the workspace_id column introduced in Phase 1 (0106) and FK'd in Phase 2 (0107).

  • 70 btree indexes <table>_workspace_id_idx on every tenant table carrying workspace_id.
  • 7 workspace-scoped partial unique indexes (WHERE workspace_id IS NOT NULL, via drizzle isNotNull) on agents / sessions / documents (workspace_id, slug), agent_skills (workspace_id, name), agent_eval_benchmarks / agent_eval_datasets / tasks (workspace_id, identifier). These pre-build the "new" half of the Phase 4 (0109) unique-constraint cutover; no existing user-scoped uniques are touched here.

The standard drizzle migration (0108_add_workspace_id_indexes.sql) is committed for schema/snapshot consistency. A separate production-safe runbook using CREATE INDEX CONCURRENTLY (ordered smallest→largest, with monitoring/cleanup notes) is run by hand against production and is intentionally not part of this PR.

Note: scope is the 70 tenant tables that actually carry workspace_id (the 3 workspace_* child tables already have their own indexes). The rbac_roles / rbac_user_roles unique/PK reshaping is deferred to Phase 4 (0109), so only 7 partial uniques are pre-built here.

πŸ§ͺ How to Test

  • Tested locally

drizzle-kit generate produces exactly 70 CREATE INDEX + 7 CREATE UNIQUE INDEX (0 DROP/ALTER); bun run type-check clean for packages/database.

  • Added/updated tests
  • No tests needed

@arvinxx arvinxx requested review from nekomeowww and tjx666 as code owners June 4, 2026 09:14
@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobehub Ready Ready Preview, Comment Jun 4, 2026 10:40am

Request Review

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 4, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @arvinxx, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@arvinxx arvinxx changed the title πŸ—ƒοΈ db(database): add workspace_id indexes (migration 0108) πŸ—ƒοΈ db(database): add workspace_id indexes Jun 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 49f3f11a88

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with πŸ‘.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/database/migrations/0108_add_workspace_id_indexes.sql Outdated
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 70.85%. Comparing base (bab3ff4) to head (f57eb96).
⚠️ Report is 2 commits behind head on canary.

Additional details and impacted files
@@             Coverage Diff             @@
##           canary   #15468       +/-   ##
===========================================
- Coverage   89.22%   70.85%   -18.37%     
===========================================
  Files         892     3255     +2363     
  Lines      108146   321009   +212863     
  Branches    10604    34992    +24388     
===========================================
+ Hits        96490   227453   +130963     
- Misses      11474    93374    +81900     
  Partials      182      182               
Flag Coverage Ξ”
app 61.52% <ΓΈ> (?)
database 92.54% <ΓΈ> (ΓΈ)
packages/agent-manager-runtime 49.69% <ΓΈ> (ΓΈ)
packages/agent-runtime 80.48% <ΓΈ> (ΓΈ)
packages/builtin-tool-lobe-agent 18.52% <ΓΈ> (ΓΈ)
packages/context-engine 84.19% <ΓΈ> (ΓΈ)
packages/conversation-flow 91.29% <ΓΈ> (ΓΈ)
packages/device-gateway-client 89.68% <ΓΈ> (ΓΈ)
packages/eval-dataset-parser 95.15% <ΓΈ> (ΓΈ)
packages/eval-rubric 76.11% <ΓΈ> (ΓΈ)
packages/fetch-sse 85.57% <ΓΈ> (-1.72%) ⬇️
packages/file-loaders 87.89% <ΓΈ> (ΓΈ)
packages/memory-user-memory 74.99% <ΓΈ> (ΓΈ)
packages/model-bank 99.99% <ΓΈ> (ΓΈ)
packages/model-runtime 84.51% <ΓΈ> (ΓΈ)
packages/prompts 72.51% <ΓΈ> (ΓΈ)
packages/python-interpreter 92.90% <ΓΈ> (ΓΈ)
packages/ssrf-safe-fetch 0.00% <ΓΈ> (ΓΈ)
packages/types 35.34% <ΓΈ> (ΓΈ)
packages/utils 84.98% <ΓΈ> (ΓΈ)
packages/web-crawler 88.08% <ΓΈ> (ΓΈ)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Ξ”
Store 68.53% <ΓΈ> (βˆ…)
Services 54.75% <ΓΈ> (βˆ…)
Server 71.85% <77.50%> (βˆ…)
Libs 57.01% <ΓΈ> (βˆ…)
Utils 81.48% <ΓΈ> (-18.52%) ⬇️
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

arvinxx and others added 2 commits June 4, 2026 18:11
Phase 3 of the workspace DB migration (LOBE-9961). Adds a btree index on
workspace_id to 70 tenant tables, plus 7 workspace-scoped partial unique
indexes (WHERE workspace_id IS NOT NULL) that pre-build the "new" side of the
Phase 4 (0109) unique-constraint cutover.

A separate production-safe runbook (0108_concurrent.sql, CREATE INDEX
CONCURRENTLY, ordered smallest->largest) is intentionally NOT committed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add IF NOT EXISTS to all 70 CREATE INDEX + 7 CREATE UNIQUE INDEX statements,
per the db-migrations standard flow (defensive/idempotent SQL), matching how
0107 used DROP CONSTRAINT IF EXISTS. Safe to re-run and safe if the concurrent
runbook already built the indexes before the auto-migrator reaches 0108.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@arvinxx arvinxx force-pushed the lobe-9961-phase-3-migration-0108-add-workspace_id-btree-indexes-create branch from d9cc216 to f57eb96 Compare June 4, 2026 10:11
@arvinxx arvinxx changed the title πŸ—ƒοΈ db(database): add workspace_id indexes πŸ—ƒοΈ build(database): add workspace_id indexes Jun 4, 2026
@arvinxx arvinxx changed the title πŸ—ƒοΈ build(database): add workspace_id indexes πŸ—ƒοΈ build(database): add workspace_id indexes Jun 4, 2026
@arvinxx arvinxx merged commit 8f19fde into canary Jun 4, 2026
34 of 35 checks passed
@arvinxx arvinxx deleted the lobe-9961-phase-3-migration-0108-add-workspace_id-btree-indexes-create branch June 4, 2026 11:03
arvinxx added a commit that referenced this pull request Jun 10, 2026
# πŸš€ LobeHub Release (20260610)

**Release Date:** June 10, 2026  
**Since v2.2.2:** 131 merged PRs Β· 13 contributors

> This weekly release strengthens agent collaboration across cloud,
desktop, CLI, and workspace flows, with steadier runtime behavior and a
broader foundation for workspace-scoped data.

---

## ✨ Highlights

- **Agent execution across devices** β€” Unifies per-device working
directories, project skill discovery, and sub-agent suspend/resume
behavior across server, QStash, and device RPC flows. (#15543, #15566,
#15481, #15620, #15591)
- **Connector and sandbox platform** β€” Expands connector permissions,
custom OAuth MCP connector onboarding, sandbox provider support, and
user-uploaded file sync into cloud sandbox runs. (#15463, #15546,
#15184, #15550)
- **Desktop and CLI reliability** β€” Fixes desktop cold-start,
auto-update, Windows build, CLI skill discovery, and `lh connect` agent
dispatch paths. (#15547, #15525, #15527, #15562, #15632, #15634)
- **Pages and sharing** β€” Refreshes topic sharing, improves Page Editor
layout behavior, and routes Page Agent tool execution through the
server-side editor path. (#15581, #15556, #15588, #15023, #15610)
- **Model availability and provider updates** β€” Adds user-scoped LobeHub
model availability, Claude Fable 5, Qwen thinking preservation, and
MiniMax M3 updates. (#15590, #15639, #13494, #15376)

---

## πŸ—οΈ Core Product & Architecture

### Agent Runtime & Heterogeneous Agents

- Improves sub-agent lifecycle handling, including async suspend/resume,
queue-mode QStash resume delivery, and blocking nested sub-agent calls.
(#15481, #15620, #15575)
- Stabilizes heterogeneous agent ingestion and streaming with raw stream
dumps, per-turn usage, image forwarding on regenerate, and
duplicate-text fixes. (#15602, #15577, #15592, #15585)
- Adds execution-device and working-directory controls across device
RPC, legacy defaults, and remote-spawned Claude Code sessions. (#15543,
#15566, #15591, #15572)
- Improves runtime diagnostics and compatibility, including Gemini
multimodal output capture, abort stream semantics, and trace quality
analysis. (#15535, #13677, #15508)

---

## πŸ“± Platforms, Integrations & UX

### Connectors, Sandbox & Tools

- Ships API-level connector tool permissions, custom OAuth MCP connector
onboarding, and connector-first runtime execution. (#15463, #15546)
- Adds sandbox provider support, cloud sandbox file sync, and safer
external URL file input handling with SSRF validation. (#15184, #15550,
#12657)
- Improves tool visibility and execution with pinned app-fixed tools,
ANSI output rendering, gateway-tunneled MCP calls, and automatic
headless tool runs. (#15509, #15516, #15469, #15492)

### Desktop, CLI & Web UX

- Restores desktop startup and reload behavior, preserves IPC error
causes, and keeps the tab bar new-tab action visible across routes.
(#15547, #15597, #15638)
- Fixes desktop update and build stability for browser quit guards,
macOS update signing, and Windows Visual Studio detection. (#15525,
#15527, #15562)
- Shows the plan-limit upgrade UI on desktop builds. (#15628)
- Adds the Agent Run delivery checker and fixes CLI device dispatch plus
skill list/search output. (#15489, #15634, #15632)
- Refreshes onboarding, auth source preservation, topic UI states,
referral/Fable campaign copy, and chat-input control bar behavior.
(#15629, #15544, #15573, #15614, #15616, #15617, #15622, #15643)

---

## πŸ”’ Security, Reliability & Rollout Notes

- External URL file input now includes SSRF validation for safer Google
file handling. (#12657)
- Database workspace-scope migrations are part of this release;
self-hosted operators should run the normal migration path before
serving the updated app. (#15446, #15465, #15468, #15472)
- The release branch was re-cut from `canary` and includes the latest
`main` release-version commit so `v2.2.2` is the verified compare base.

---

## πŸ‘₯ Contributors

@ONLY-yours, @sxjeru, @hardy-one, @xujingli, @hezhijie0327, @Coooolfan,
@arvinxx, @tjx666, @Innei, @rivertwilight, @rdmclin2, @cy948,
@AmAzing129

**Full Changelog**:
v2.2.2...release/weekly-20260610-recut-3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant