class CreateCourseMemberAttendances < ActiveRecord::Migration[5.2]
  def change
    create_table :course_member_attendances do |t|
      t.references :course_member, index: true
      t.references :user
      t.references :course, index: true
      t.references :course_attendance
      t.references :course_group, index: true
      t.integer :attendance_mode, default: 0
      t.integer :attendance_status, default: 0

      t.timestamps
    end

    add_index :course_member_attendances, [:course_attendance_id, :user_id], unique: true, name: "index_on_user_attendance"
  end
end
