add Match model

This commit is contained in:
2026-11-03 16:14:10 +03:00
parent 1cadf00280
commit f48094cd55
6 changed files with 236 additions and 1 deletions
@@ -0,0 +1,24 @@
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