class CreateHackUserCodes < ActiveRecord::Migration[5.2] def change create_table :hack_user_codes do |t| t.references :user t.references :hack t.text :code t.text :output t.text :error_msg t.integer :error_line t.integer :position t.integer :status, default: 0 t.integer :query_index t.timestamps end add_index :hack_user_codes, [:user_id, :hack_id, :query_index], unique: true end end