MIgration Problem in 2.1.2

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
20090301004033
20090222224734
20090217193953
over and over. It’s like it gets lost and can’t find what one it did
last.

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

Thanks,
–Colin

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
command.

–Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs