Class: WineDb::CreateDb

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/winedb/schema.rb

Instance Method Summary collapse

Instance Method Details

#downObject

method up

Raises:

  • (ActiveRecord::IrreversibleMigration)


198
199
200
# File 'lib/winedb/schema.rb', line 198

def down
  raise ActiveRecord::IrreversibleMigration
end

#upObject



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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/winedb/schema.rb', line 8

def up

#######
# todo/fix:  rename title to name



###
# wines
#
# note: key is NOT unique; require winery key
#  winery.key+wines.key => unique key  e.g.  antonbauer.gruenerveltiner

create_table :wines do |t|
  t.string  :key,     null: false   # import/export key
  t.string  :title,   null: false
  t.string  :synonyms  # comma separated list of synonyms

  t.references :winery   # optional (for now)
  t.references :variety  # optional (for now) -- todo/fix:  make required!!! why not??? possible??

  t.string  :web    # optional url link (e.g. )
  t.integer :since  # optional year (e.g. 1896)

  t.references :country, null: false
  t.references :region   # optional
  t.references :city     # optional
  t.references :vineyard # optional e.g. Spiegel, Gmoerk, Rosenberg, etc.

  t.string  :txt            # source ref
  t.boolean :txt_auto, null: false, default: false     # inline? got auto-added?

  t.timestamps
end


create_table :wineries do |t|
  t.string  :key,      null: false   # import/export key
  t.string  :title,    null: false
  t.string  :synonyms  # comma separated list of synonyms
  t.string  :address
  t.integer :since   ## renamed founded to since
  t.integer :closed  # optional;  year winery closed

  t.integer :area    # in ha e.g. 8 ha   # Weingarten/rebflaeche

  # use stars in .txt e.g. # ***/**/*/- => 1/2/3/4
  t.integer :grade, null: false, default: 4

  t.string  :web        # optional web page (e.g. www.ottakringer.at)
  t.string  :wikipedia  # optional wiki(pedia page)


  t.references :country,  null: false
  t.references :region   # optional
  t.references :city     # optional

  t.references :person  # optional for now   - winemaker/kellermeister e.g. Anton Bauer (1971) etc.
  t.references :tavern  # optional (heurige)

  t.string  :txt            # source ref
  t.boolean :txt_auto, null: false, default: false     # inline? got auto-added?

  t.timestamps
end

create_table :vintages do |t|
  t.integer    :year,  null: false
  t.references :wine,  null: false

  ## check: why decimal and not float? 
  t.decimal    :abv    # Alcohol by volume (abbreviated as ABV, abv, or alc/vol) e.g. 4.9 %

  t.timestamps  
end

create_table :grapes do |t|
  t.string   :key,      null: false   # import/export key
  t.string   :title,    null: false
  t.string   :synonyms  # comma separated list of synonyms

  t.boolean  :red,   null: false, default: false
  t.boolean  :white, null: false, default: false

  t.integer  :since
  t.string   :web        # optional web page
  t.string   :wikipedia  # optional wiki(pedia page)

  t.timestamps
end

####
# wine families
#
#  todo/fix: allow subfamilies e.g. red wine => 1) red wine varietal, 2) red wine blended/cuvee etc.

create_table :families do |t|  # wine family e.g.  red wine/white wine/rose wine/sparkling(champagne,etc.)/desert(sweet)/fortified(port,etc.)/other etc.
  t.string     :key,      null: false   # import/export key
  t.string     :title,    null: false
  t.string     :synonyms  # comma separated list of synonyms

  t.timestamps
end

####
# wine variety
#  e.g. varietal (Gr. Veltiner) or blend/cuvee (Red Wine Cuvee) etc.
create_table :varieties do |t|
  t.string     :key,      null: false   # import/export key
  t.string     :title,    null: false
  t.string     :synonyms  # comma separated list of synonyms
  t.references :family,   null: false

  ## note: for now cuvee will NOT record blended varieties (maybe add later??)
  t.boolean    :cuvee,    null: false, default: false  # blended variety
  t.boolean    :varietal, null: false, default: false
  t.references :grape    # note: optional - only varietal has a main grape (+80%); cuvee/blended is a mix of grapes
  t.timestamps
end

##########################
# (Wine)Taverns/Heurige

create_table :taverns do |t|
  t.string     :key,      null: false   # import/export key
  t.string     :title,    null: false
  t.string     :synonyms  # comma separated list of synonyms
  t.references :winery    # for now optional -- todo/fix: make required!!!

  t.string  :address
  t.integer :since

  t.string   :web        # optional web page (e.g. www.urbaniheuriger.at)
  t.string   :wikipedia  # optional wiki(pedia page)

  t.references :country,  null: false
  t.references :region   # optional
  t.references :city     # optional

  t.string  :txt            # source ref
  t.boolean :txt_auto, null: false, default: false     # inline? got auto-added?

  t.timestamps
end


#################################
# (Wine)Shops/Vinothek/Enoteca

create_table :shops do |t|
  t.string  :key,      null: false   # import/export key
  t.string  :title,    null: false
  t.string  :synonyms  # comma separated list of synonyms

  t.string  :address
  t.integer :since

  t.string  :web        # optional web page (e.g. www.ottakringer.at)
  t.string  :wikipedia  # optional wiki(pedia page)

  t.references :country,  null: false
  t.references :region   # optional
  t.references :city     # optional

  t.string  :txt            # source ref
  t.boolean :txt_auto, null: false, default: false     # inline? got auto-added?

  t.timestamps
end


################
# vineyards
#
# e.g. Spiegel, Rosenberg, Gmoerk, etc.

create_table :vineyards do |t|
  t.string     :key,      null: false   # import/export key
  t.string     :title,    null: false
  t.string     :synonyms   # comma separated list of synonyms
  t.references :city,     null: false

  t.integer :area    # in ha e.g. 8 ha   # Weingarten/rebflaeche

  t.timestamps
end


end