简体   繁体   中英

Rails 3: “Schema migrations table does not exists yet”

So some months ago, for some reason I got a weird git message and was afraid to deploy. So I started making changes to the production application directly and trying to also manually make the same changes to my local code.

So now the time came to update everything, I wanted to sync my local code with the production code and start using git and capistrano to deploy again. So I downloaded the code from the production server and copy pasted some files into my local code to make sure I wasn't going to overwrite anything on the production server.

I'm now able to run cap:deploy and everything seems to work as expected. Problem is, I created a new column on my dev copy and I was about to run cap deploy:migrate but I'm afraid it's going to wipe out my production database.

So I ran rake db:migrate:status and I get the message Schema migrations table does not exists yet. I already checked my production database and the schema migrations table IS there. So it seems the app is not recognizing my current migration version and I'm afraid that if I run cap deploy:migrate is going to run ALL the migrations and wipe out my database.

Why am I getting this message? What should I do?

My situation may be somewhat different from you but I too got the same message. I was in development in my local PC with Rails 4.

Try using only db:migrate .

A solution I've found is to use abort_if_pending_migrations:

export RAILS_ENV=production; bundle exec rake db:abort_if_pending_migrations

This seems to print nothing if your migrations are up-to-date, and list tables that need updating if they are not. This is with Rails 4.1.8.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM