{"record":{"id":"5402530f4bb222cf","repo":"gastownhall/beads","slug":"uow-database-q-has-no-beads-schema-the-schema","errorCode":null,"errorMessage":"uow: database %q has no beads schema — the schema is managed by beads-team-server; ask your operator to run 'bts init' first","messagePattern":"uow: database %q has no beads schema — the schema is managed by beads-team-server; ask your operator to run 'bts init' first","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/uow/team_server_schema.go","lineNumber":21,"sourceCode":"import (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/steveyegge/beads/internal/storage/issueops\"\n\t\"github.com/steveyegge/beads/internal/storage/schema\"\n)\n\n// checkTeamServerSchema verifies that a bts-managed database's schema version\n// matches this binary's. The connection must already have the database selected.\nfunc checkTeamServerSchema(ctx context.Context, conn schema.DBConn, database string) error {\n\tcurrent, err := schema.CurrentVersion(ctx, conn)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"uow: team-server schema check: %w\", err)\n\t}\n\tlatest := schema.LatestVersion()\n\tswitch {\n\tcase current == 0:\n\t\treturn fmt.Errorf(\n\t\t\t\"uow: database %q has no beads schema — the schema is managed by beads-team-server; ask your operator to run 'bts init' first\",\n\t\t\tdatabase)\n\tcase current > latest:\n\t\treturn schema.CheckForwardDrift(ctx, conn)\n\tcase current < latest:\n\t\t// No BD_IGNORE_SCHEMA_SKEW hatch here: it would let a newer bd write\n\t\t// against an older bts schema. Not SchemaBehindError either: its \"run\n\t\t// any bd write command to migrate\" advice is wrong for a bts-owned schema.\n\t\treturn fmt.Errorf(\n\t\t\t\"uow: database %q is at schema v%d, this bd expects v%d; the schema is managed by beads-team-server — ask your operator to run 'bts migrate', or use a bd built against schema v%d\",\n\t\t\tdatabase, current, latest, current)\n\t}\n\treturn nil\n}\n\n// checkTeamServerIdentity verifies that the bts-managed database this\n// invocation is about to open really belongs to the calling workspace's\n// project. The connection must already have the database selected.","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/uow/team_server_schema.go#L3-L39","documentation":"checkTeamServerSchema verifies that the target Dolt database has a beads schema (a nonzero schema version) before bd will operate on it. In team-server mode the schema is owned by beads-team-server, so bd refuses to act on a database with no beads schema and tells the operator to provision it with 'bts init' instead of migrating it itself.","triggerScenarios":"Running any bd write/command against a --database that resolves to a Dolt database whose metadata/schema version reads 0 (fresh DB or schema table missing) while verifyTeamServerSchema is active.","commonSituations":"Typoed or default --database name pointing at an empty database; operator created the database but never ran 'bts init'; the team server was provisioned after clients connected; database was recreated (dropped and re-added) without re-init.","solutions":["Have the operator run 'bts init' on the database to provision the beads schema","Verify the --database / dolt_database name in .beads/metadata.json points at the bts-provisioned database","Re-run bd init --team-server after the database is provisioned"],"exampleFix":"// before\nbd sync --database beads_wrong  # uow: database has no beads schema\n// after\nbts init --database beads   # operator provisions schema\nbd sync --database beads","handlingStrategy":"validation","validationCode":"-- preflight: confirm the database was provisioned by bts before running bd\nSELECT schema_version FROM information_schema.tables ...  -- or run: bts status --database <name>","typeGuard":"func isNoBeadsSchema(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \"has no beads schema\")\n}","tryCatchPattern":"err := bdSync(ctx)\nif isNoBeadsSchema(err) {\n  // surface operator action, not a client retry\n  return fmt.Errorf(\"operator must run 'bts init' on the database: %w\", err)\n}","preventionTips":["Always run 'bts init' before pointing bd clients at a new database","Pin the --database / dolt_database name in .beads/metadata.json and avoid typos","Document the bts-init prerequisite in team onboarding","Check bts status after any database recreate/restore"],"tags":["database","schema","team-server","initialization"],"backgroundTag":"schema-not-initialized","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}