lib/sportdb/schema.rb in sportdb-models-1.18.1 vs lib/sportdb/schema.rb in sportdb-models-1.18.2
- old
+ new
@@ -139,17 +139,28 @@
end
add_index :groups, :event_id # fk event_id index
+create_table :stages do |t| # e.g. regular season, champions round, etc.
+ t.references :event, null: false, index: false ## Note: do NOT auto-add index
+ t.string :title, null: false
+ t.timestamps
+end
+
+add_index :stages, :event_id # fk event_id index
+
+
+
###########################
# fix: rename table to matches
create_table :games do |t|
t.string :key # import/export key
t.references :round, null: false, index: false ## Note: do NOT auto-add index
t.integer :pos, null: false
t.references :group, index: false ## Note: do NOT auto-add index -- group is optional
+ t.references :stage, index: false # optional - regular seasion / champions round etc.
t.references :team1, null: false, index: false ## Note: do NOT auto-add index
t.references :team2, null: false, index: false ## Note: do NOT auto-add index
t.datetime :play_at, null: false
t.boolean :postponed, null: false, default: false
@@ -195,32 +206,44 @@
t.references :event, null: false, index: false ## Note: do NOT auto-add index
t.references :team, null: false, index: false ## Note: do NOT auto-add index
t.timestamps
end
-add_index :events_teams, [:event_id,:team_id], unique: true
+add_index :events_teams, [:event_id, :team_id], unique: true
add_index :events_teams, :event_id
# todo: remove id from join table (without extra fields)? why?? why not??
+create_table :stages_teams do |t|
+ t.references :stage, null: false, index: false ## Note: do NOT auto-add index
+ t.references :team, null: false, index: false ## Note: do NOT auto-add index
+ t.timestamps
+end
+
+add_index :stages_teams, [:stage_id, :team_id], unique: true
+add_index :stages_teams, :stage_id
+
+
+
+# todo: remove id from join table (without extra fields)? why?? why not??
create_table :events_grounds do |t|
t.references :event, null: false, index: false ## Note: do NOT auto-add index
t.references :ground, null: false, index: false ## Note: do NOT auto-add index
t.timestamps
end
-add_index :events_grounds, [:event_id,:ground_id], unique: true
+add_index :events_grounds, [:event_id, :ground_id], unique: true
add_index :events_grounds, :event_id
create_table :groups_teams do |t|
t.references :group, null: false, index: false ## Note: do NOT auto-add index
t.references :team, null: false, index: false ## Note: do NOT auto-add index
t.timestamps
end
-add_index :groups_teams, [:group_id,:team_id], unique: true
+add_index :groups_teams, [:group_id, :team_id], unique: true
add_index :groups_teams, :group_id
### todo: add models and some seed data