Skip to content

feat(databases): share a database with the owner's team - #8603

Merged
404Wolf merged 9 commits into
mainfrom
wolf/database-team-sharing
Oct 23, 2026
Merged

404Wolf merged 9 commits into
mainfrom
wolf/database-team-sharing

Conversation

@404Wolf

@404Wolf 404Wolf commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Why

Database owners on a team couldn't give their teammates access to a
database without adding them one person or one channel at a time. Split
out of #8367 so the Notion import PR keeps only import code. #8367 stacks
on this migration and keeps its exact version.

How it works

The team share uses the same share_permission_db_utils::team_share
writer as documents, threads and sessions. A database gets a
SharePermission row (database_entities.share_permission_id) the first
time its owner changes sharing. Its grant is a team-source entity_access
row, so rows, listing and Soup read it like any other grant.

PATCH /databases/{id}/permissions { teamShareAccessLevel, channels }
  └─ one transaction: ensure SharePermission row → team_share::apply
                      → channel grants

What

  • Migration 20261021183145_database_team_sharing.sql: adds the
    share_permission_id column. The delete trigger now removes the
    database's sharing settings along with the entity.
  • share_permission_db_utils: accepts databases. A database with no
    permission row reads as unshared, and a trashed database counts as
    deleted.
  • databases: the sharing service reads and writes
    teamShareAccessLevel in the same transaction as channel grants. Only
    the actual owner can change it, an owner with no team gets a clear
    error, and a share that changed since authorization returns 409.
    Includes a real-Postgres teammate access test.
  • Web: the database share dialog offers Team access, sent through the
    database permissions endpoint.
  • Regenerated the storage OpenAPI, web client, SDK and SDK docs. Updated
    the databases agent guide and crates/databases/AGENTS.md.

Why: databases could not be shared with the owner's team because the
team share writer only knew documents, threads, sessions and the other
shareable entities, and databases had nowhere to keep sharing state.

What:
- Add `database_entities.share_permission_id`, a SharePermission row
  made the first time the owner changes sharing; the delete trigger
  removes it with the entity.
- Teach `share_permission_db_utils::team_share` to load and apply a
  database's team share, read a database without a permission row as
  unshared, and treat a trashed database as deleted.
Why: owners on a team had no way to give their teammates access to a
database short of sharing it person by person or channel by channel.

What:
- The sharing service reads and writes `teamShareAccessLevel` alongside
  channel grants, in one transaction.
- Only the actual owner may change the team share; an owner with no
  team gets a clear error, and a share that changed since authorization
  returns 409.
- Teammates reach the database through a team-source `entity_access`
  grant, covered by a real-Postgres test.
…sure

Why: CI's dependency check fails when the generated closure map lags Cargo.toml.
Why: the backend now stores a database's team share, but the share
dialog only offered people and channels for databases.

What:
- Treat databases as team-shareable and send the team access level
  through the database permissions endpoint.
- Regenerate the storage OpenAPI, web client, SDK and SDK docs for the
  team share and the new 409 response.
- Describe Team access in the databases agent guide.
@404Wolf
404Wolf requested a review from a team as a code owner October 22, 2026 22:55
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 8b035c4 and edb18f9.

⛔ Files ignored due to path filters: 10
  • .sqlx/query-37d8d63b28d3c57a726897d59a38a1d77b3fb111c59186eaf8300d4fc6c2403b.json is excluded by !**/.sqlx/**
  • .sqlx/query-58d824f76ec5f0dbb0a6607c2574fd5540f3e1a6e36d343500b7f70bb007401b.json is excluded by !**/.sqlx/**
  • .sqlx/query-739a30b2ae7711752ecf7971ba176c02e79b38d8846f5ec782b5967af95c3a84.json is excluded by !**/.sqlx/**
  • .sqlx/query-ad741c642b2f5d0f04e79ceaf64c0c8f3cbbc0d6bffcc3eac9864030486fa61c.json is excluded by !**/.sqlx/**
  • .sqlx/query-e4dd957d19dc07703f1c78cd3e2980d0c4eb86b8723fe7fadfc26c8a8080f5dd.json is excluded by !**/.sqlx/**
  • Cargo.lock is excluded by !**/*.lock, !**/Cargo.lock
  • apps/web/src/lib/service-clients/service-storage/generated/zod.ts is excluded by !**/generated/**, !apps/web/src/lib/service-clients/**/generated/**
  • packages/sdk-docs/reference/generated/storage/types.gen/type-aliases/UpdateDatabasePermissionsErrors.md is excluded by !**/generated/**
  • packages/sdk/generated/storage/sdk.gen.ts is excluded by !**/generated/**, !**/*.gen.ts
  • packages/sdk/generated/storage/types.gen.ts is excluded by !**/generated/**, !**/*.gen.ts
📒 Files selected for processing: 26
  • .github/workspace-dep-closures.json
  • apps/web/src/lib/core/component/TopBar/ShareButton.test.tsx
  • apps/web/src/lib/core/component/TopBar/ShareButton.tsx
  • apps/web/src/lib/core/component/TopBar/linkShare.ts
  • apps/web/src/lib/service-clients/service-storage/openapi.json
  • crates/databases/AGENTS.md
  • crates/databases/Cargo.toml
  • crates/databases/src/domain/models/schema_error.rs
  • crates/databases/src/domain/service/sharing.rs
  • crates/databases/src/domain/service/test/fakes.rs
  • crates/databases/src/domain/service/test/sharing.rs
  • crates/databases/src/domain/sharing.rs
  • crates/databases/src/inbound/axum_router.rs
  • crates/databases/src/inbound/axum_router/sharing.rs
  • crates/databases/src/outbound/pg_databases_repo.rs
  • crates/databases/src/outbound/pg_databases_repo/sharing.rs
  • crates/databases/src/outbound/pg_databases_repo/test.rs
  • crates/databases/src/outbound/pg_databases_repo/test/sharing.rs
  • crates/databases/src/outbound/pg_databases_repo/test/team_share.rs
  • crates/entity_access/src/outbound/pg_access_repo/queries/database_access.rs
  • crates/macro_db_client/migrations/20261021183145_database_team_sharing.sql
  • crates/share_permission_db_utils/AGENTS.md
  • crates/share_permission_db_utils/src/team_share.rs
  • crates/share_permission_db_utils/src/team_share/test.rs
  • docs/agent-guide/databases.md
  • packages/sdk/specs/storage.json

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.

📝 Summary

Summary by CodeRabbit

  • New Features
    • Database owners can now share databases with their team using view, comment, or edit access. Team members’ access follows the selected level, including access to database rows.
    • Team-sharing controls are available when the owner belongs to a team. Only the database owner can change team access.
  • Bug Fixes
    • Changes to database sharing are now detected when permissions change during an update, preventing outdated changes from being applied.
  • Documentation
    • Updated database-sharing guidance to explain team access and clarify that database link sharing is unavailable.

Database permissions now support owner-controlled team sharing. The change adds database team-share persistence and authorization, combines team-share commands with channel-grant updates, and returns HTTP 409 when sharing facts change after authorization. Database team access is reflected in permission reads and the sharing interface. Tests cover access levels, authorization failures, access to databases and rows, and cleanup of associated permission records.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to edb18

No confirmed issue currently prevents merging the database team-sharing change after normal checks.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title follows conventional commits format, uses the feat prefix, is 55 characters long, and accurately describes database team sharing.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The PR description explains the purpose and mechanics of the change: database owners can share a database with their team. It names the migration, the share_permission_db_utils writer, the databases s…
Full details: Description check

Explanation

The PR description explains the purpose and mechanics of the change: database owners can share a database with their team. It names the migration, the share_permission_db_utils writer, the databases sharing service, the web Team access control, and the regenerated OpenAPI, SDK, and docs. This matches the changeset summaries, so the description is related and specific.

✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

… users

Why: databases now call team_share, and the crate guide's Used by list left them out.
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

…till exists

Why: #8474 removed CLAUDE_BOT_ID while #8364 added a channel name test
that uses it, so the channels lib tests stopped compiling on main.
Why: #8474 dropped the @claude system bot, so the DM fixture's bot now
resolves as "Bot" and the name search test no longer finds "Claude" on main.
…aring

# Conflicts:
#	crates/channels/src/outbound/channel_name/test.rs
@404Wolf
404Wolf merged commit 95fe363 into main Oct 23, 2026
37 checks passed
@404Wolf
404Wolf deleted the wolf/database-team-sharing branch October 23, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant