# Plan 32-01 Summary: Schema Migration (isPublic -> visibility)

**Status:** Complete
**Commit:** edc9793

## What was done

1. **Schema changes** (`src/db/schema.ts`):
   - Replaced `isPublic: boolean` with `visibility: text` (default "private") on setups table
   - Added `shares` table with columns: id, setupId, token, permission, expiresAt, userId, createdAt, revokedAt
   - Removed `boolean` import from drizzle-orm/pg-core

2. **Migration** (`drizzle-pg/0005_true_green_goblin.sql`):
   - Creates shares table with FK constraints
   - Adds visibility column with data migration (`UPDATE setups SET visibility = 'public' WHERE is_public = true`)
   - Drops is_public column

3. **Full-stack isPublic -> visibility replacement** across 16 files:
   - `src/shared/schemas.ts`: `z.enum(["private", "link", "public"])` replaces `z.boolean()`
   - `src/server/services/setup.service.ts`: createSetup, getAllSetups, updateSetup
   - `src/server/services/discovery.service.ts`: `eq(setups.visibility, "public")`
   - `src/server/services/profile.service.ts`: Two occurrences updated
   - `src/server/routes/account.ts`: Delete account reassignment query
   - `src/client/hooks/useSetups.ts`: Types and mutation signatures
   - `src/client/components/SetupCard.tsx`: Visibility badge (public=green, link=blue)
   - `src/client/components/SetupsView.tsx`: Passes visibility prop
   - `src/client/routes/setups/$setupId.tsx`: Temporary visibility badge with lock/link/globe icons
   - `src/db/dev-seed.ts` and `src/db/dev-seed-data.ts`: Seed data updated

4. **Tests updated** across 4 test files (46 tests pass):
   - `tests/services/profile.service.test.ts`
   - `tests/services/discovery.service.test.ts`
   - `tests/routes/discovery.test.ts`
   - `tests/routes/profiles.test.ts`
   - `tests/helpers/db.ts`: Added shares to truncation list

## Verification

- `bun run lint`: Passes (0 errors)
- All affected tests pass (46/46)
- Zero isPublic/is_public references in src/ (except unrelated `isPublicRoute` in __root.tsx)
- Zero isPublic references in tests/
