Skip to content

feat: add local development seed data (Closes #405)#443

Merged
PRODHOSH merged 2 commits into
PRODHOSH:mainfrom
SakethSumanBathini:feat/405-seed-data
Jul 14, 2026
Merged

feat: add local development seed data (Closes #405)#443
PRODHOSH merged 2 commits into
PRODHOSH:mainfrom
SakethSumanBathini:feat/405-seed-data

Conversation

@SakethSumanBathini

@SakethSumanBathini SakethSumanBathini commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

supabase/seed.sql currently contains no SQL at all — just a comment explaining that none is needed,
because profiles are created by the handle_new_user trigger when someone signs in.

That's true, and it leaves anyone without GitHub OAuth configured — or without a Supabase project at
all — looking at an empty Explore, an empty Discover, and a /compare with nobody to compare. You
can't develop against any of it.

This adds five profiles with realistic, varied data.

Related Issue

Closes #405

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor
  • Chore / dependency update

Changes Made

One file: supabase/seed.sql.

It seeds auth.users, not public.profiles, and that's forced by the schema. profiles.id is
references auth.users(id) on delete cascade, so a profile row cannot exist without an auth user —
inserting straight into public.profiles fails on the foreign key. So the seed does what a real
GitHub sign-in does: it inserts an auth user with GitHub-shaped raw_user_meta_data and lets
handle_new_user build the profile from it.

That also keeps the file honest. If the trigger changes, the seed follows it, rather than drifting
into a second parallel definition of what a profile looks like.

Stats are then applied with an UPDATE, because the trigger only sets identity fields (username,
name, avatar_url, github_url). Score and totals normally arrive from the GitHub sync, which needs a
service-role key and network access that local dev often doesn't have — which is precisely the
situation this file exists to rescue.

The data is chosen so the features have something to exercise:

  • a clear top of the leaderboard and a long tail, so Explore's ordering is visible
  • one large positive score_delta_30_days and one negative, so the "most improved" sort added in
    20260710000000 has something to actually sort
  • overlapping languages, so the Discover language filter is worth clicking
  • one profile deliberately unlisted — it renders at /lena-ships but must not appear on Explore
    or in /api/discover. That behaviour is easy to break and hard to notice without an example
    sitting in the database

on conflict (id) do nothing, so supabase db reset can be re-run and this is a no-op against a
database that already has them.

AI Usage

  • I did not use AI for any part of the code in this PR
  • I used AI for coding (specify which tool below) and I fully understand every change I made,
    including which functions I changed, why I changed them, and what side effects they could create

Used Claude for coding.

Checklist

  • I was assigned to the issue before opening this PR
  • My branch is up to date with main
  • Code works locally and I have tested it
  • No console.log left in src/
  • If schema changed — both schema.sql and a new migration file are included
  • If this is a UI change — I read DESIGN.md and followed the design system
  • Docs updated if needed
  • PR title follows Conventional Commits format
  • This PR description is written in my own words

(No schema change — this only inserts data. No UI change.)

How I tested it

I don't have a Supabase project, so I applied the schema and the actual handle_new_user trigger,
lifted verbatim from 20260520000001_initial_schema.sql
, to a local Postgres and ran the seed
against it:

  • the trigger fires and creates all five profiles from the auth users — usernames, names, avatars and
    GitHub URLs all populated from raw_user_meta_data
  • a listing filtered to visibility = 'public' returns four of them in score order, and correctly
    excludes the unlisted one
  • running the file a second time is a clean no-op — the profile count stays at five

What I couldn't test: supabase db reset end-to-end against a real Supabase instance. The SQL is
verified against the real trigger and a real Postgres; the CLI wiring around it I've had to take on
trust. If the auth.users column set differs from what I've assumed on your version, that'll show up
immediately on the first reset and I'll fix it.

  • the trigger fires and creates all five profiles from the auth users
  • every user has an auth.identities row with sub matching its user id, so GoTrue can authenticate
    them — verified against GoTrue's real constraints (provider_id NOT NULL, unique on
    (provider, provider_id))
  • a listing filtered to visibility = 'public' returns four in score order, correctly excluding the
    unlisted one
  • running the file twice is a clean no-op — five users, five identities, five profiles either way

Summary by CodeRabbit

  • Chores
    • Expanded local development seed data with multiple sample user profiles and realistic profile statistics.
    • Added public and unlisted profile examples, including varied score trends and language data.
    • Made seed data safe to re-run without creating duplicate users or profiles.

@github-actions

Copy link
Copy Markdown
Contributor

Welcome to OSSfolio, @SakethSumanBathini! 🎉

Thank you for opening this pull request and contributing to the open-source community! 🚀

To ensure a smooth review process, please make sure you have:

  • Checked that your changes work locally and compile cleanly.
  • Followed the guidelines outlined in CONTRIBUTING.md.
  • Linked your PR to an open issue (e.g. Closes #ISSUE_NUMBER).

We will review your PR as soon as possible. Happy coding! 💻✨

@github-actions github-actions Bot added the backend Supabase / API / database label Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The seed script now creates deterministic local auth users, relies on the auth trigger for profiles, and populates profile statistics, language data, score deltas, and visibility settings. Inserts are idempotent, and one profile is marked unlisted.

Changes

Local development seed

Layer / File(s) Summary
Auth user seeding
supabase/seed.sql
Documents the local seed workflow and inserts deterministic GitHub-shaped users into auth.users with conflict-safe behavior.
Profile data population
supabase/seed.sql
Updates seeded profiles with identity data, statistics, language data, score deltas, and public or unlisted visibility.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A bunny hops through seeded rows,
With GitHub names and stats in tow.
Public scores leap, deltas gleam,
One stays tucked from Explore’s stream.
Idempotent carrots grow!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR seeds data in SQL, but issue #405 specifically asked for a Node.js seed script, 10 mock users, and an npm run db:seed command. Add scripts/seed.ts using the Supabase Admin client, seed 10 mock users, and wire up npm run db:seed in package.json.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changes stay focused on local development seed data and related profile visibility behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding local development seed data.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@supabase/seed.sql`:
- Around line 25-100: Add matching auth.identities seed rows for each inserted
user in the auth.users seed block, using the corresponding user IDs and provider
identity data required by GoTrue for GitHub login. Make the identity inserts
idempotent with an appropriate conflict guard, preserving the existing
auth.users data and confirmation fields.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 90c187be-5d0b-4a39-9e6d-b4d4724076a2

📥 Commits

Reviewing files that changed from the base of the PR and between 294511e and 90c9018.

📒 Files selected for processing (1)
  • supabase/seed.sql

Comment thread supabase/seed.sql
@PRODHOSH PRODHOSH self-requested a review July 14, 2026 03:01
@PRODHOSH PRODHOSH added enhancement New feature or improvement ELUSOC ELUSOC project submission completed ADVENTURER Intermediate — 25 pts labels Jul 14, 2026
@PRODHOSH PRODHOSH merged commit 21b10b8 into PRODHOSH:main Jul 14, 2026
11 of 12 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Your PR just got merged, @SakethSumanBathini — thank you for contributing to OSSfolio!

Your work is now part of the project. Here's what to do next:

  • ⭐ If you haven't already, consider giving the repo a star — it helps us grow.
  • 📢 Share your contribution on LinkedIn, Twitter, or wherever you hang out. You shipped open source!
  • 🔍 Browse other open issues if you want to keep contributing.

We really appreciate you taking the time. See you in the next PR! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ADVENTURER Intermediate — 25 pts backend Supabase / API / database completed ELUSOC ELUSOC project submission enhancement New feature or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CHORE] Create a database seed script for local development

2 participants