I appear to have a circular issue in regards to Ruby on Rails migration procedure. I am following the introduction article and I have reached the point when I need to creat
Check to make sure that table doesn't already exist:
drop table TABLENAME;
One weird trick that you can use when your migrations are screwed (file deleted, manually renamed, etc.)
schema_migrations
and browse its content. It should have a single column called version
. This field is used by Rails to check whether migrations are up to date. It may happened because you've added new columns to a table with old data that is now missing values. I've had the same problem with my test database and fixed it just by running
$ rails db:setup
CAUTION
It deletes all of the data. This command runs rails db:reset
, rails db:migrate
and rails db:seed
try In RAILS_ROOT/config/environments/development.rb Set the following setting to false:
config.active_record.migration_error = false#:page_load
this was what i did:
rails db:environment:set RAILS_ENV=test
If you need to do it manually
rake db:schema:load RAILS_ENV=test
and then
bundle exec rake db:migrate
Thanks to Ahmed Ali....... your comment was helpful.
You need to do
bundle exec rake test:prepare
or
bundle exec rake db:test:prepare
and then
bundle exec rake db:migrate
before running the specs
Cheers
cited from : Why am I asked to run 'rake db:migrate RAILS_ENV=test'?