-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.rb
executable file
·71 lines (58 loc) · 1.53 KB
/
model.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env ruby
require 'rubygems'
require 'dm-core'
require 'dm-migrations'
DataMapper.setup :default, "postgres://buyyourvalues:buyyourvalues@localhost/buyyourvalues"
class Business
include DataMapper::Resource
belongs_to :business_category
has n, :contributors
property :id, Serial
property :name, String, :length => 100
property :latitude, String
property :longitude, String
end
class Contributor
include DataMapper::Resource
has n, :contributions
belongs_to :business
property :id, Serial
property :name, String, :length => 100
property :type, String
property :zipcode, String
property :address, String, :length => 256
property :city, String
property :state, String
property :occupation, String
end
class Contribution
include DataMapper::Resource
belongs_to :contributor
belongs_to :recipient
property :id, Serial
property :amount, Float
property :date, DateTime
end
class Recipient
include DataMapper::Resource
has n, :contributions
property :id, Serial
property :name, String, :length => 100
property :state, String
property :party, String
property :election_type, String
property :seat, String
property :district, String
end
# They're all restaurants, but in case we ever deal with more
class BusinessCategory
include DataMapper::Resource
has n, :businesses
property :id, String, :key => true
property :source, String
property :name, String, :length => 100
property :industry, String
property :order, String
end
DataMapper.finalize
DataMapper.auto_upgrade!