-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.rb
43 lines (38 loc) · 1.11 KB
/
setup.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'csv'
load 'config/ar.rb' if ARGV[0] == '--init'
if ActiveRecord::Base.connection.table_exists? 'players'
p 'players table already exists'
else
ActiveRecord::Schema.define do
create_table :players do |t|
t.column :player_id, :string
t.column :first_name, :string
t.column :last_name, :string
t.column :birth_year, :integer
end
add_index :players, :player_id
end
end
if ActiveRecord::Base.connection.table_exists? 'statistics'
p 'statistics table already exists'
else
ActiveRecord::Schema.define do
create_table :statistics do |t|
t.column :player_id, :string
t.column :year_id, :integer
t.column :league, :string
t.column :team_id, :string
t.column :games, :integer
t.column :at_bat, :integer
t.column :runs, :integer
t.column :hits, :integer
t.column :doubles, :integer
t.column :triples, :integer
t.column :home_runs, :integer
t.column :runs_batted_in, :integer
t.column :stolen_bases, :integer
t.column :caught_stealing, :integer
end
add_index :statistics, :player_id
end
end