class CreateCourseAttendanceGroups < ActiveRecord::Migration[5.2] def change create_table :course_attendance_groups do |t| t.references :course, index: true t.references :course_attendance t.references :course_group, index: true t.timestamps end add_index :course_attendance_groups, [:course_attendance_id, :course_group_id, :course_id], name: "course_group_attendance", unique: true end end