Board Web Seed Strategy
Goals:
- Easily seed QA environment
- Ensure every engineer has the same seed data in their locals
Two ways we can achieve this:
- Seed each model independently
- Seed based on a group of models that provide a functionality for a business process.
Overview
Random values that make sense
It's generally acceptable to use random values for seed data, but they must make sense.
BAD
- Job Title: 'asdasdas'
GOOD
- Job Title: 'Kitchen Helper'
Please use Faker gem so that random values that make sense.
Use business logic/flow to seed.
Consider the flow of a user creating a Careers::UserProfile.
| step | model created |
|---|---|
| User signs up for the first time | Identities::User |
User navigated to Careers::UserProfile | ` |
If we were to just seed Identities::User independently of Careers::UserProfile and Org::UserProfile
- we would spend some time thinking about how to split the existing
Identities::Userwhen seedingCareers::UserProfileandOrg::UserProfile
Consider the following seed logic.
# Seed::Development::Identities
[1..10].each() do |count|
Identities::User.create(...)
end
# Seed::Development::Careers::UserProfile
[1..5].each() do |count|
Careers::UserProfile.create(
identities_user_id: count
# ...
)
end
# Seed::Development::Org::UserProfile
# If Careers::UsersProfile was executed first, we would have 5 Identities::User with both a Careers::UserProfile and Org::UserProfile
[1..6].each() do |count|
Org::UserProfile.create(
identities_user_id: count
)
end
Issue here is that we are not creating the models like how they would be created in production.
User Archetypes
Careers User
We have two types of users:
Org::UserProfile(org_user)Careers::UserProfile(careers_user)
When creating a careers_user we want to seed:
Identities::UserCareers::UserProfileCareers::UserExperiencesCareers::UserSkillsCareers::UserCertificatesCareers::UserEducation
Org User
When creating an org_user, we want to seed:
Identities::UserOrg::UserProfileOrg::CompanyCareers::Job
Careers::Job is linked to an Org::UserProfile and Org::Company
Handling different model states.
Model state refers to a particular set of values a model has during the business process.
For example, a Careers::Job has the attribute status with the values:
:draft:open:hidden:closed
Which status should we use?
- choose the status that makes sense.
- it's totally fine to seed multiple rows in the db with different values.
- For example, we can say
- I would like the company I seed to have 3 jobs of each statuses so that filtering via status will always show a result in my local.
- For example, we can say
Back to creating an org_user with Orgcompany and Careers::Job, we would want to