Skip to content

Implement Database Seed Script #1

@balebbae

Description

@balebbae

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:

  1. Uncomment the code in cmd/migrate/seed/main.go
  2. Run:
    make seed
    

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

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions