docs: update Task 3 design for removed dead-code scenario
Update the per-user-profile plan document to reflect the corrected Task 3 design: remove the now-unreachable TestClaimLegacyOwner_NoOpOnGenuinelyFreshInstall test from the code example, update the ClaimLegacyOwner implementation example to remove the dead-code branch and false doc comment about fresh installs, and fix the commit message to match the corrected design. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -693,7 +693,6 @@ package store
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -704,8 +703,7 @@ import (
|
|||||||
// new user identified by oidcSub. Safe to call on every startup: once the
|
// new user identified by oidcSub. Safe to call on every startup: once the
|
||||||
// users table is non-empty, it's a no-op, so leaving
|
// users table is non-empty, it's a no-op, so leaving
|
||||||
// GENIUSRUN_LEGACY_OWNER_OIDC_SUB set after the first successful run causes
|
// GENIUSRUN_LEGACY_OWNER_OIDC_SUB set after the first successful run causes
|
||||||
// no harm. Also a no-op on a genuinely fresh install (no legacy profile row
|
// no harm.
|
||||||
// to claim at all).
|
|
||||||
func (db *DB) ClaimLegacyOwner(ctx context.Context, oidcSub string) error {
|
func (db *DB) ClaimLegacyOwner(ctx context.Context, oidcSub string) error {
|
||||||
var userCount int
|
var userCount int
|
||||||
if err := db.QueryRowContext(ctx, `SELECT COUNT(*) FROM users`).Scan(&userCount); err != nil {
|
if err := db.QueryRowContext(ctx, `SELECT COUNT(*) FROM users`).Scan(&userCount); err != nil {
|
||||||
@@ -717,9 +715,6 @@ func (db *DB) ClaimLegacyOwner(ctx context.Context, oidcSub string) error {
|
|||||||
|
|
||||||
var displayName string
|
var displayName string
|
||||||
err := db.QueryRowContext(ctx, `SELECT name FROM profile WHERE user_id IS NULL LIMIT 1`).Scan(&displayName)
|
err := db.QueryRowContext(ctx, `SELECT name FROM profile WHERE user_id IS NULL LIMIT 1`).Scan(&displayName)
|
||||||
if err == sql.ErrNoRows {
|
|
||||||
return nil // fresh install, no pre-existing singleton profile to claim
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("find legacy profile: %w", err)
|
return fmt.Errorf("find legacy profile: %w", err)
|
||||||
}
|
}
|
||||||
@@ -763,8 +758,7 @@ git commit -m "$(cat <<'EOF'
|
|||||||
store: add ClaimLegacyOwner one-time upgrade bootstrap
|
store: add ClaimLegacyOwner one-time upgrade bootstrap
|
||||||
|
|
||||||
Binds pre-multi-tenancy singleton rows to one named OIDC subject, given at
|
Binds pre-multi-tenancy singleton rows to one named OIDC subject, given at
|
||||||
startup via an env var (wired in Task 11). No-ops once any user exists or
|
startup via an env var (wired in Task 11). No-ops once any user exists.
|
||||||
on a genuinely fresh install.
|
|
||||||
EOF
|
EOF
|
||||||
)"
|
)"
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user