Skip to content

Create new ExperimentSubject model with user_id, group_id, or project_id

Create a new ExperimentSubject model and the associated experiment_subjects table. Include all of the columns from the existing experiment_users table, including the user_id column, and also add group_id and project_id columns. Add a constraint which stipulates that at least one of user_id, group_id, or project_id must have a value.

In more detail:

  • create a new experiment_subjects table, leave the existing experiment_users table as-is
  • give the new experiment_subjects table the same columns as the existing experiment_users table
  • give the new experiment_subjects table additional columns for group_id and project_id
  • add a constraint to the new experiment_subjects table which stipulates that at least one of user_id, group_id, or project_id must have a value
  • create a new ExperimentSubject model
  • add an Experiment#has_many :experiment_subjects relationship
Edited by Dallas Reedy