Move group scores into separate table
This commit is contained in:
parent
579412ab89
commit
b742b3ed67
|
|
@ -0,0 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class GroupScore < ApplicationRecord
|
||||||
|
belongs_to :team
|
||||||
|
end
|
||||||
|
|
@ -2,4 +2,6 @@
|
||||||
|
|
||||||
class Team < ApplicationRecord
|
class Team < ApplicationRecord
|
||||||
belongs_to :tournament
|
belongs_to :tournament
|
||||||
|
|
||||||
|
has_one :group_score, dependent: :destroy
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,18 @@ class CreateSchema < ActiveRecord::Migration[5.2]
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table :group_scores do |t|
|
||||||
|
t.integer :score, default: 0
|
||||||
|
t.integer :points_scored, default: 0
|
||||||
|
t.integer :points_received, default: 0
|
||||||
|
|
||||||
|
t.belongs_to :team, index: { unique: true }, foreign_key: { on_delete: :cascade }, null: false
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
create_table :teams do |t|
|
create_table :teams do |t|
|
||||||
t.string :name
|
t.string :name
|
||||||
t.integer :group_score
|
|
||||||
t.integer :group_points_scored
|
|
||||||
t.integer :group_points_recieved
|
|
||||||
|
|
||||||
t.belongs_to :tournament, index: true, null: false, foreign_key: { on_delete: :cascade }
|
t.belongs_to :tournament, index: true, null: false, foreign_key: { on_delete: :cascade }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue