1

I have my schema.rb file updated with all the changes that I had mentioned in my migration files. However, when I try to setup my db,

I get an error saying "You have 30 pending migrations".

As far as I know, the schema.rb doesn't get updated if a migration is not run.

To get over this, I tried to do a rake db:schema:load and then tried to seed the database. Even then, I got an error message saying "You have 30 pending migrations".

Can someone help me?

2 Answers 2

3

Migrations are a way to manage changes to your current schema.

If your schema already matches what you want, you can toss the migrations and just move on to seeding your db. Of course, rake db:seed will first attempt to run any migrations, so delete them from the folder first.

Rails creates a table called migrations and actually records the IDs of migrations that have been run on that database. If you're deploying your app to a new database instance, and have run rake db:schema:load on it, then its migrations table will be empty and you'll have problems whenever something calls migrate, unless you get rid of the migration files you don't need.

1
  • I agree with your approach. My app is under version control and If i delete the migration files, I will need to pull them sometime later. This does help me running the seeds script without any problems. But then, I realized the root cause of my problem : I am using redis gem in the current and in another repository that I cloned. Changing the namespace names in few other config files helped me get through the entire database setup process without any sort of discrepancies. Thanks for your answer, at least I got to learn something that I wasn't aware. :) Feb 20, 2013 at 8:58
0

Have you tried

rake db:migrate

?

5
  • Yes I did. It throws me an error saying column "xyz" already exists...Which is exactly what the first of 30 pending migrations does. Feb 20, 2013 at 6:37
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post.
    – David Cain
    Feb 20, 2013 at 6:44
  • @MurthyUpadhyayula Do you have some double things on your database? I had this problem before also, I try to make my migration doesn't clash with any thing on my database..
    – ksugiarto
    Feb 20, 2013 at 8:49
  • 1
    @David thanks sir, I just try to help since my reputation make me can't comment on any post yet, and since my knowledge not advanced yet to describing the answer, I just try to help with what I know, Thanks
    – ksugiarto
    Feb 20, 2013 at 8:49
  • If you mean two repositories by saying "Double things", then yes. I just had common name space names in few config files used by common gems in both the repos. I just changed the namespace names and things started to work. While I am on that, I would also say that bdares is right. We can just delete the migration files that are causing the trouble and run the setup. You can pull them later on (if your repo is using some SVC) :) Feb 20, 2013 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.