I'm getting an error when trying to run rake db:migrate
:
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column "plus_ids" of relation "comments" does not exist
I guess I did do some funky stuff when trying to remove the attribute plus_ids from my comment model. I'm not sure what is going on.
If I do a rake db:reset
and then fetch the live database it all works locally again, but if I try to do a rake db:migrate
it throws an error again.
How can I get rid of plus_ids properly so I can migrate?
Edit 1: Here's the migration files when I added (and removed) the attribute:
class RemovePlusIdsFromComments < ActiveRecord::Migration
def change
remove_column :comments, :plus_ids, :integer
end
end
And then
class AddPlusIdsToComments < ActiveRecord::Migration
def change
add_column :comments, :plus_ids, :integer
end
end
They're in the wrong order in the migration list, not sure why.
Edit 2: I think there is something wrong with the Up/Down, if I run rake db:migrate:status
I get this:
down 20150305203336 Remove plus ids from comments
down 20150305204404 Add plus ids to comments
Any way around this?
The answer was to run
rake db:migrate:up VERSION=20150305204404
On both live and local, and then
rake db:migrate
On both again. Now the live and local database is in sync again, and migrating the database throws no errors.
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.