Move group scores into separate table

This commit is contained in:
Thor77 2018-11-13 23:10:57 +01:00
parent 579412ab89
commit b742b3ed67
No known key found for this signature in database
GPG Key ID: 5051E71B46AA669A
3 changed files with 17 additions and 3 deletions

View File

@ -0,0 +1,5 @@
# frozen_string_literal: true
class GroupScore < ApplicationRecord
belongs_to :team
end

View File

@ -2,4 +2,6 @@
class Team < ApplicationRecord
belongs_to :tournament
has_one :group_score, dependent: :destroy
end

View File

@ -30,11 +30,18 @@ class CreateSchema < ActiveRecord::Migration[5.2]
t.timestamps
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|
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 }