This situation is a good reason to get
very comfortable with the ActiveRecord::SchemaDumper class, as it will allow us to check just what state
our database is in at any given time (and act accordingly).We??™ll show the SchemaDumper in action within our
example code in a minute.
Migrations in Action
Because the concept of migrations is somewhat of a paradigm shift for most of us traditional
developer types (those of us coming from a background other than Ruby or Ruby on Rails),
CHAPTER 3 ?– SETTING UP YOUR DATABASE 50
we??™ve found that some examples can make learning migrations easier. Examples go a long way
in helping to point out the specific details and situations involved in implementing migrations.
Let??™s pretend that we need to build an application that is going to track information about
milk production. We??™ll have information about farmers, cows, milk, and various other milk
production issues (some of which we will recognize and retrofit as needed). The overall basic
concept of our example will be to report on how much a given farmer sells milk to various
stores for.
Pages:
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