schema_info always wants to be 3, even when set to 7

Hi all,

I'm having a very odd problem with db:migrate. I'm using Rails 1.2.5 on Windows XP SP2 and Ruby 1.8.6

I have seven migrations. If I run them with an empty database, it runs the first three, then halts. When I look in schema_info, the version is 3.

If I run db:migrate VERSION=7, then it runs through the remaining 4 migrations, and the version is 7 in the DB. Committed and everything.

If I then run db:migrate on its own, then Rails will REVERT BACK those 4 migrations and set the version to 3 again.

I don't understand this behaviour. I've tried --trace and --verbose and neither explains why it is that Rails wants to roll back when the version is 7.

I've only just recently arrived to Rails and Rake, so I'm not familiar with the internal structure, but I don't see this behaviour mentioned in any of the documentation. Can anyone help?

Will.

It would be beneficial if you can send us the output that is presented to you while you do the db:migrate. Specially from migrating your db schema to an empty database.

Dima

D:\home\wsargent\work\blog3>rake db:migrate (in D:/home/wsargent/work/blog3) == CreatePosts: migrating

You likely have an environment variable named VERSION that is set to 3 (or something that .to_i makes into 3).

Since you're on Windows, see what the output from:

  set

shows to you. (Of course, the Unix equivalent is `env` for those playing along at home.)

If you don't need that variable for something else, try:

  unset VERSION

or always specify the VERSION when you migrate:

  rake db:migrate VERSION=7

Please post back if this solves your problem.

-Rob

Thanks; that's exactly what I would have never thought of.

D:\home\wsargent\work\blog3>echo %VERSION% 3.5.0

Nasty. I wonder what software was responsible for installing that?

Will.

I always feel a great satisfaction when individual problems are solved by the community. Thanks you all out there one more time for your effort.

Dima

Mr. Biedenharn, I am very grateful to observe your answer here and find the implications of viewing ones' SET variables as instrumental to running on a Windows XP machine. Would you by chance know how to change these at the DOS command line? Thank you, Kathleen

It's been a while since I've had a Windows system around, but I
believe either:   unset VERSION or possibly:   set VERSION= might work.

If you're actually in Windows, not DOS, you can go to ControlPanel- >System->Environment and remove the setting of the VERSION variable.
(The details of getting to that window are only approximate!)

-Rob