class CreateMatches < ActiveRecord::Migration[8.1] def change create_table :matches do |t| t.string :uuid, null: false t.references :player1, null: false, foreign_key: { to_table: :users } t.references :player2, null: false, foreign_key: { to_table: :users } t.integer :status, null: false, default: 0 t.text :game_server, null: false t.datetime :started_at, null: false t.datetime :finished_at t.integer :duration_seconds t.integer :player1_rating_before, null: false t.integer :player2_rating_before, null: false t.integer :player1_rating_change, null: false, default: 0 t.integer :player2_rating_change, null: false, default: 0 t.timestamps end add_index :matches, :uuid, unique: true add_index :matches, [ :player1_id, :finished_at ] add_index :matches, [ :player2_id, :finished_at ] end end