Skip to content

feat(profile): add central extended_profiles schema (Phase 0) - #13470

Open
h0lybyte wants to merge 1 commit into
devfrom
feat/profile-extended-schema
Open

feat(profile): add central extended_profiles schema (Phase 0)#13470
h0lybyte wants to merge 1 commit into
devfrom
feat/profile-extended-schema

Conversation

@h0lybyte

Copy link
Copy Markdown
Member

Summary

Proto-first profile consolidation to establish single source of truth for user identity fields (bio, location, avatar, links) before data duplication spreads across apps.

Approach: Define proto contract first → generate Zod/TS/Rust → create SQL matching proto.

Changes

Proto Layer

  • ✅ Add ExtendedProfile + ProfileLink messages to kbve/profile.proto
  • ✅ Update jobboard.proto to reference kbve.profile.ProfileLink (remove duplicate)
  • ✅ Add TalentProfile.extended field for future JOIN to central profile

Code Generation

  • ✅ Regenerate Rust proto (jobboard + kbve modules with serde support)
  • ✅ Regenerate TypeScript proto via buf generate
  • ✅ Add ProfileLinkSchema + ExtendedProfileSchema to Zod barrel

SQL Schema

  • ✅ Create profile.extended_profiles table (user_id PK, bio, location, avatar_url, links, updated_at)
  • ✅ Migration: 20260628014652_profile_extended_init.sql
  • ✅ Add validation functions: is_valid_profile_links(), set_updated_at()
  • ✅ Add RLS policies: users can CRUD own profile, service-role full access

Schema Details

CREATE TABLE profile.extended_profiles (
    user_id    UUID PRIMARY KEY REFERENCES auth.users(id) ON DELETE CASCADE,
    bio        TEXT NOT NULL DEFAULT '' CHECK (length(bio) <= 5000),
    location   TEXT NOT NULL DEFAULT '' CHECK (length(location) <= 120),
    avatar_url TEXT NOT NULL DEFAULT '' CHECK (length(avatar_url) <= 2048),
    links      JSONB NOT NULL DEFAULT '[]' CHECK (is_valid_profile_links(links)),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

Constraints:

  • bio: max 5000 chars
  • location: max 120 chars
  • avatar_url: max 2048 chars
  • links: max 20 items, HTTPS only, validated kinds (github/linkedin/website/x/itch/artstation/other)

RLS Policies:

  • service_role_full_access: full CRUD
  • user_read_own: users can SELECT own profile
  • user_update_own: users can UPDATE own profile
  • user_insert_own: users can INSERT own profile (one-time)

Files Changed

Proto

  • packages/data/proto/kbve/profile.proto - ExtendedProfile + ProfileLink
  • packages/data/proto/jobboard/jobboard.proto - Reference kbve.profile types

Generated Code

  • apps/jobboard/src/proto/kbve.profile.rs - NEW (Rust proto)
  • apps/jobboard/src/proto/kbve.common.rs - NEW (Rust proto)
  • apps/jobboard/src/proto/jobboard.rs - Updated (TalentProfile.extended)
  • apps/jobboard/build.rs - Compile kbve proto + add serde
  • apps/jobboard/src/main.rs - Export kbve proto modules
  • packages/data/codegen/generated/profile-schema.ts - Add Zod schemas

SQL

  • packages/data/sql/schema/profile/extended_profiles.sql - Schema source
  • packages/data/sql/dbmate/migrations/20260628014652_profile_extended_init.sql - Migration

Testing

  • ✅ Proto compiled (Rust + TypeScript)
  • ✅ Zod schemas type-check
  • ⏸️ SQL migration not applied yet (Phase 0 - schema definition only)

Next Steps (Tracked in #13465)

Phase 1: Backfill existing data

  • Migrate from jobboard.talent_profiles (bio, location, links)
  • Migrate from meme.meme_user_profiles (bio, avatar_url)

Phase 2: Code migration

  • Update Axum REST handlers to JOIN profile.extended_profiles
  • Update jobboard vetting to write to central profile
  • Regenerate proto + update frontend

Phase 3: Schema cleanup

  • Drop redundant columns from jobboard.talent_profiles
  • Drop redundant columns from meme.meme_user_profiles
  • Drop orphaned validation functions

Related

Closes #13465 (Phase 0 only - schema definition)


🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Proto-first profile consolidation to avoid data duplication across apps.

Changes:
- Add ExtendedProfile + ProfileLink messages to kbve/profile.proto
- Update jobboard.proto to reference kbve.profile.ProfileLink
- Add TalentProfile.extended field for central profile JOIN
- Regenerate Rust proto (jobboard + kbve modules)
- Regenerate TypeScript proto via buf generate
- Add ProfileLinkSchema + ExtendedProfileSchema to Zod barrel
- Create profile.extended_profiles SQL schema + migration
- Add RLS policies (users can CRUD own profile, service-role full access)
- Add validation functions (is_valid_profile_links, set_updated_at)

SQL Schema:
- profile.extended_profiles (user_id PK, bio, location, avatar_url, links, updated_at)
- Constraints: bio ≤5000, location ≤120, avatar_url ≤2048, links ≤20 items (HTTPS only)
- Kinds: github, linkedin, website, x, itch, artstation, other

Migration: 20260628014652_profile_extended_init.sql

Next phases (tracked in #13465):
- Phase 1: Backfill from jobboard.talent_profiles + meme.meme_user_profiles
- Phase 2: Update Axum handlers to JOIN central profile
- Phase 3: Drop redundant columns from app tables

Issue: #13465

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant