# MIgration Problem in 2.1.2

**URL:** <https://www.ruby-forum.com/t/migration-problem-in-2-1-2/162280>\
**Category:** Rails\
**Created:** [March 8, 2009, 2:10am UTC](https://www.ruby-forum.com/t/migration-problem-in-2-1-2/162280 "2009-03-08T02:10:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![banry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/898d66/32.png) [@banry](https://www.ruby-forum.com/u/banry)\
**Post date:** [March 8, 2009, 2:10am UTC](https://www.ruby-forum.com/t/migration-problem-in-2-1-2/162280/1 "2009-03-08T02:10:52Z")

</div>

# 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

---

<div class="post-metadata">

**Author:** ![banry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/898d66/32.png) [@banry](https://www.ruby-forum.com/u/banry)\
**Post date:** [March 9, 2009, 5:51pm UTC](https://www.ruby-forum.com/t/migration-problem-in-2-1-2/162280/2 "2009-03-09T17:51:40Z")

</div>

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
