lib/sportdb/schema.rb in sportdb-models-1.16.2 vs lib/sportdb/schema.rb in sportdb-models-1.17.0
- old
+ new
@@ -31,13 +31,13 @@
###########
# check: use table (rename to) venues / stadiums - why? why not?
create_table :grounds do |t|
t.string :key, null: false # import/export key
- t.string :title, null: false
+ t.string :title, null: false
t.string :synonyms # comma separated list of synonyms
-
+
t.references :country, null: false
t.references :city # todo: make city required ???
t.integer :since # founding year
t.integer :capacity # attentence capacity e.g. 10_000 or 50_000 etc.
@@ -46,11 +46,11 @@
### fix/todo: add since/founded/opened/build attrib eg. 2011 or 1987
## - add capacity e.g. 40_000
## fix: add address !!!! etc
- ## add region ??? or just use region from city ??
+ ## add region ??? or just use region from city ??
t.timestamps
end
add_index :grounds, :key, unique: true
@@ -65,11 +65,11 @@
t.integer :minute
t.integer :offset, null: false, default: 0 # e.g. 45' +3 or 90' +2
t.integer :score1
t.integer :score2
-
+
## type of goal (penalty, owngoal)
t.boolean :penalty, null: false, default: false
t.boolean :owngoal, null: false, default: false # de: Eigentor -> # todo: find better name?
t.timestamps
@@ -109,11 +109,11 @@
add_index :events, :key, unique: true
create_table :rounds do |t|
- t.references :event, null: false
+ t.references :event, null: false, index: false ## Note: do NOT auto-add index
t.string :title, null: false
t.string :title2
t.integer :pos, null: false
## add new table stage/stages for grouping rounds in group rounds and playoff rounds, for example???
## # "regular" season (group) games or post-season (playoff) knockouts (k.o's)
@@ -130,27 +130,28 @@
add_index :rounds, :event_id # fk event_id index
create_table :groups do |t| # Teamgruppe (zB Gruppe A, Gruppe B, etc.)
- t.references :event, null: false
+ t.references :event, null: false, index: false ## Note: do NOT auto-add index
t.string :title, null: false
t.integer :pos, null: false
t.timestamps
end
add_index :groups, :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
+ t.references :round, null: false, index: false ## Note: do NOT auto-add index
t.integer :pos, null: false
- t.references :group # note: group is optional
- t.references :team1, null: false
- t.references :team2, null: false
+ t.references :group, index: false ## Note: do NOT auto-add index -- group is optional
+ 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
t.datetime :play_at_v2 # optional old date (when postponed)
t.datetime :play_at_v3 # optional odl date (when postponed twice)
@@ -169,15 +170,15 @@
t.integer :score2p # penalty - team 2 (opt) elfmeter (opt)
t.integer :score1i # half time / first third (opt)
t.integer :score2i # half time - team 2
t.integer :score1ii # second third (opt)
t.integer :score2ii # second third - team2 (opt)
- t.references :next_game # for hinspiel bei rueckspiel in knockout game
- t.references :prev_game
+ t.references :next_game, index: false ## Note: do NOT auto-add index -- for hinspiel bei rueckspiel in knockout game
+ t.references :prev_game, index: false ## Note: do NOT auto-add index
t.integer :winner # 1,2,0,nil calculate on save - "real" winner (after 90 or extra time or penalty, aggregated first+second leg?)
- t.integer :winner90 # 1,2,0,nil calculate on save - winner after 90 mins (or regugular play time depending on sport - add alias or find a better name!)
+ t.integer :winner90 # 1,2,0,nil calculate on save - winner after 90 mins (or regugular play time depending on sport - add alias or find a better name!)
t.timestamps
end
add_index :games, :key, unique: true
@@ -189,34 +190,34 @@
add_index :games, :team2_id
# todo: remove id from join table (without extra fields)? why?? why not??
create_table :events_teams do |t|
- t.references :event, null: false
- t.references :team, null: false
+ 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
# todo: remove id from join table (without extra fields)? why?? why not??
create_table :events_grounds do |t|
- t.references :event, null: false
- t.references :ground, null: false
+ 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
create_table :groups_teams do |t|
- t.references :group, null: false
- t.references :team, null: false
+ 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
@@ -232,11 +233,11 @@
create_table :leagues do |t| ## also for cups/conferences/tournaments/world series/etc.
t.string :key, null: false
t.string :title, null: false # e.g. Premier League, Deutsche Bundesliga, World Cup, Champions League, etc.
t.references :country ## optional for now , :null => false ### todo: create "virtual" country for international leagues e.g. use int? or world (ww?)/europe (eu)/etc. similar? already taken??
-
+
## fix: rename to :clubs from :club
t.boolean :club, null: false, default: false # club teams or national teams?
## todo: add t.boolean :national flag? for national teams?
## t.boolean :international, :null => false, :default => false # national league or international?
## t.boolean :cup ## or regular season league??
@@ -275,12 +276,12 @@
add_index :assocs, :key, unique: true
create_table :assocs_assocs do |t|
- t.references :assoc1, null: false # parent assoc
- t.references :assoc2, null: false # child assoc is_member_of parent assoc
+ t.references :assoc1, null: false, index: false ## Note: do NOT auto-add index -- parent assoc
+ t.references :assoc2, null: false, index: false ## Note: do NOT auto-add index -- child assoc is_member_of parent assoc
t.timestamps
end
add_index :assocs_assocs, [:assoc1_id,:assoc2_id], unique: true
add_index :assocs_assocs, :assoc1_id
@@ -357,17 +358,17 @@
t.integer :drawn
t.integer :goals_for # todo: find a short name - gf? why? why not?
t.integer :goals_against # todo: find a shorter name - ga? why? why not?
t.integer :pts
t.integer :recs # note: specific to alltime - stats records counter (e.g. appearance counter)
- t.string :comments
+ t.string :comments
t.timestamps
end
end # Schema.define
end # method up
end # class CreateDb
-end # module SportDb
\ No newline at end of file
+end # module SportDb