Implement database seeding for development test data
Background
The seed runner at cmd/migrate/seed/main.go is already written and ready to use (currently commented out). It calls db.Seed(store, conn), which still needs to be implemented.
An example seed file exists at internal/db/seed.go from another project (a blog application with users, posts, and comments). This example is for reference only — you need to write a new seed that matches the current database schema.
Task
Implement internal/db/seed.go to generate test data for the current schema.
Tables to seed
1. users
Generate approximately 50–100 test users.
supertokens_user_id: Generate fake IDs (e.g. seed-user-{i})
email: Use pattern like user{i}@example.com
role: Mix of hacker, admin, super_admin (mostly hackers)
auth_method: Mix of passwordless and google
profile_picture_url: Optional; may be NULL or placeholder URLs
2. applications
Generate applications for users with the hacker role.
- Mix of statuses:
draft
submitted
accepted
rejected
waitlisted
- Realistic fake data for:
- names
- universities
- majors
- other profile fields
short_answer_responses:
- Stored as
JSONB
- Keys must match default questions:
why_attend
hackathons_learned
first_hackathon_goals
looking_forward
dietary_restrictions:
- Array of enum values (
vegan, vegetarian, halal, etc.)
- For submitted applications:
submitted_at must be set
- Acknowledgment fields must be true
Implementation notes
- Use existing store methods:
store.Users.Create
store.Applications.Create
- etc.
- Wrap user creation in a transaction (as shown in the example seed)
- Use random selection from arrays of realistic sample data
- Ensure referential integrity:
- Applications must reference existing users
- Applications with
status = 'submitted' must have:
ack_application = true
ack_mlh_coc = true
ack_mlh_privacy = true
- (required by database constraints)
Files to modify
internal/db/seed.go
- Uncomment and rewrite the
Seed function
- Implement any required helper generators
How to run
After implementation:
- Uncomment the code in
cmd/migrate/seed/main.go
- Run:
Acceptance criteria
- Seed creates 50–100 users with varied roles
- Seed creates applications for hacker users
- Applications contain realistic and varied data
- A mix of application statuses is present
- Submitted applications satisfy all database constraints
- Seed is idempotent or gracefully handles existing data
- make seed runs successfully
Implement database seeding for development test data
Background
The seed runner at
cmd/migrate/seed/main.gois already written and ready to use (currently commented out). It callsdb.Seed(store, conn), which still needs to be implemented.An example seed file exists at
internal/db/seed.gofrom another project (a blog application with users, posts, and comments). This example is for reference only — you need to write a new seed that matches the current database schema.Task
Implement
internal/db/seed.goto generate test data for the current schema.Tables to seed
1.
usersGenerate approximately 50–100 test users.
supertokens_user_id: Generate fake IDs (e.g.seed-user-{i})email: Use pattern likeuser{i}@example.comrole: Mix ofhacker,admin,super_admin(mostly hackers)auth_method: Mix ofpasswordlessandgoogleprofile_picture_url: Optional; may beNULLor placeholder URLs2.
applicationsGenerate applications for users with the
hackerrole.draftsubmittedacceptedrejectedwaitlistedshort_answer_responses:JSONBwhy_attendhackathons_learnedfirst_hackathon_goalslooking_forwarddietary_restrictions:vegan,vegetarian,halal, etc.)submitted_atmust be setImplementation notes
store.Users.Createstore.Applications.Createstatus = 'submitted'must have:ack_application = trueack_mlh_coc = trueack_mlh_privacy = trueFiles to modify
internal/db/seed.goSeedfunctionHow to run
After implementation:
cmd/migrate/seed/main.goAcceptance criteria