Marnen Laibow-Koser wrote:
> How? You're not normally going to be running old migrations. What
> specific problem do you think you will run into if you leave the
> old migrations around?
I moved the complete database from my interim server to the permanent
one. This database had been modified by the data migrations and in
the meantime some data has been changed. So it's not a good idea, to
rerun the data migrations on the new server.
To prevent this, I locally removed the data migrations on the new
server before migrating.
On my developmentsystem, they're still present and dont harm, but I
guess, they will be pushed up to the server again with my next update
and will get run, because there is no corresponding entry in the
migration data base.
Why is there no corresponding entry in the database? If you initialize a
database from db/schema.rb, an entry is created in the migrations table
indicating the version of the schema.
Maybe, the simplest solution will be, to do something to make them
null migrations on the development system.
Just throw them away. If you can.
Migrations are tools for changing the structure of a database from one
version to the next. They have no lasting value. In particular,
migrations are *not* the right means to re-create a database. For that,
db/schema.rb + rake db:schema:load is the proper way.
Also, migrations are not supposed to add data to the database, apart
from changes necessary for migrating the structure. For adding data,
there are db/seeds.rb and rake db:seed. It's good idea to write
db/seeds.rb in such a way that it can be run again and again without
causing harm.
In summary, if you're worried that old migrations may inadvertently be
applied to your database, make sure that it contains a suitable entry in
its migrations table indicating the actual version of the schema.
Michael