Phase 13, part 1: a Postgres schema per team

On the multi-tenant edition each team's data is in its own schema; the
tables every team shares (people, sessions, memberships, keys, locks, and
a new teams table) stay in the main one. A team's connection pool searches
its own schema first, so the app's SQL runs unchanged and can't reach
another team's tables. Each request is served by a copy of the Server for
the viewer's team, with that team's database, secrets and caches; agents
work on their own team's. The local and server editions are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 12:08:47 -07:00
co-authored by Claude Opus 5.5
parent ff5eaa9784
commit 0e695ac810
24 changed files with 1037 additions and 289 deletions
+21 -2
View File
@@ -110,8 +110,27 @@ type routes struct {
unmapped []string
}
func (rt *routes) HandleFunc(pattern string, fn http.HandlerFunc) {
rt.Handle(pattern, fn)
// HandleFunc registers a handler: a method expression such as
// (*Server).seoPage, run on the Server for the request's team; or a plain
// handler that needs no team.
func (rt *routes) HandleFunc(pattern string, fn any) {
switch f := fn.(type) {
case func(*Server, http.ResponseWriter, *http.Request):
rt.Handle(pattern, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts, err := rt.s.teamServer(r)
if err != nil {
rt.s.serverError(w, err)
return
}
f(ts, w, r)
}))
case func(http.ResponseWriter, *http.Request):
rt.Handle(pattern, http.HandlerFunc(f))
case http.HandlerFunc:
rt.Handle(pattern, f)
default:
panic(fmt.Sprintf("route %s: a handler of type %T", pattern, fn))
}
}
func (rt *routes) Handle(pattern string, h http.Handler) {