Add StudyGroups with ExternalUsers only
This commit is contained in:
13
db/migrate/20181122084546_create_study_groups.rb
Normal file
13
db/migrate/20181122084546_create_study_groups.rb
Normal file
@ -0,0 +1,13 @@
|
||||
class CreateStudyGroups < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :study_groups do |t|
|
||||
t.string :name
|
||||
t.string :external_id
|
||||
t.belongs_to :consumer
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :study_groups, [:external_id, :consumer_id], unique: true
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,8 @@
|
||||
class CreateStudyGroupMemberships < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :study_group_memberships do |t|
|
||||
t.belongs_to :study_group
|
||||
t.belongs_to :user, polymorphic: true
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddStudyGroupToSubmission < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_reference :submissions, :study_group, index: true, null: true, foreign_key: true
|
||||
end
|
||||
end
|
20
db/schema.rb
20
db/schema.rb
@ -315,6 +315,24 @@ ActiveRecord::Schema.define(version: 2018_11_29_093207) do
|
||||
t.index ["submission_id"], name: "index_structured_errors_on_submission_id"
|
||||
end
|
||||
|
||||
create_table "study_group_memberships", force: :cascade do |t|
|
||||
t.bigint "study_group_id"
|
||||
t.string "user_type"
|
||||
t.bigint "user_id"
|
||||
t.index ["study_group_id"], name: "index_study_group_memberships_on_study_group_id"
|
||||
t.index ["user_type", "user_id"], name: "index_study_group_memberships_on_user_type_and_user_id"
|
||||
end
|
||||
|
||||
create_table "study_groups", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "external_id"
|
||||
t.bigint "consumer_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["consumer_id"], name: "index_study_groups_on_consumer_id"
|
||||
t.index ["external_id", "consumer_id"], name: "index_study_groups_on_external_id_and_consumer_id", unique: true
|
||||
end
|
||||
|
||||
create_table "submissions", force: :cascade do |t|
|
||||
t.integer "exercise_id"
|
||||
t.float "score"
|
||||
@ -323,7 +341,9 @@ ActiveRecord::Schema.define(version: 2018_11_29_093207) do
|
||||
t.datetime "updated_at"
|
||||
t.string "cause", limit: 255
|
||||
t.string "user_type", limit: 255
|
||||
t.bigint "study_group_id"
|
||||
t.index ["exercise_id"], name: "index_submissions_on_exercise_id"
|
||||
t.index ["study_group_id"], name: "index_submissions_on_study_group_id"
|
||||
t.index ["user_id"], name: "index_submissions_on_user_id"
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user