Forum: Ruby on Rails MIgration Problem in 2.1.2

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
59d2de0dc2028141540521eb2360c40a?d=identicon&s=25 Colin Summers (Guest)
on 2009-03-08 02:10
(Received via mailing list)
I suspect this is because it is a 1.x application which was upgraded,
but my migrations don't "stick." If I
Coder-iMac:patton colin$ rake db:migrate
(in /Users/colin/Desktop/patton)
== 20090217193953 AddLastYearToTarget: migrating
== 20090217193953 AddLastYearToTarget: migrated (0.0001s)

== 20090222192059 AddEditorToUser: migrating
== 20090222192059 AddEditorToUser: migrated (0.0000s)

== 20090222224734 AddSometTimestamps: migrating
== 20090222224734 AddSometTimestamps: migrated (0.0000s)

== 20090301004033 AddCommentRangeToUser: migrating
== 20090301004033 AddCommentRangeToUser: migrated (0.0000s)

If I do the same command again it does EXACTLY the same three
migrations. (Of course, they were all throwing errors, since they had
already done the migration once, so now the lines that do anything are
commented out.)

The table schema_migrations has 147 rows, with the last three being
over and over. It's like it gets lost and can't find what one it did

Is there some way to say, "Dump all that migration data, assume
everything has been migrated in to the latest migration?"

59d2de0dc2028141540521eb2360c40a?d=identicon&s=25 Colin Summers (Guest)
on 2009-03-09 17:51
(Received via mailing list)
I fixed it. I don't like poking around in MySQL. It's like putting my
hands in the wood chipper.

I did
   mysqldump -u user --database development_database > backup.sql
then I dropped the whole database and recreated it's name.

I did
   rake db:schema:load
to recreate all of the tables. I saw some cool command go by saying
"assume_migration(20090309)" or something like that. So I have a
feeling that real Rails weenie would be able to do this with the One
Correct Command.

I tried
  rake db:migrate
but it choked on the three new migrations, those which were named with
the date-time stamp. So I went into those and commented out everything
in self.up. I retried
   rake db:migrate
and it happily pulled them in. I held my breath and did
   rake db:migrate
again and it was quiet. Phew. So they had "stuck."

I exported the schema_migrations table to migration.sql, uploaded that
to my production server. I went into mysql and did
   drop table schema_migrations
then went out to the prompt and did
   mysql -u user --database production_database < migration.sql
and it read it in. I did
   rake db:migrate
and it seemed to stick.

I'm sure other people have run into this (or will) and there's
probably a bunch of scripts out there which do what I did, but
automagically. I wish there were just a
   rake db:fix_migrations

This topic is locked and can not be replied to.