class CreateSubjectUserInfos < ActiveRecord::Migration[5.2] def change create_table :subject_user_infos do |t| t.references :user t.references :subject t.string :username t.integer :passed_myshixun_count, default: 0 t.integer :passed_games_count, default: 0 t.integer :code_line_count, default: 0 t.integer :evaluate_count, default: 0 t.integer :cost_time, default: 0 t.timestamps end add_index :subject_user_infos, [:user_id, :subject_id], unique: true end end