I updated to rails 4.2 from 4.1 recently. Not sure if that fact is
related
to my problem or not. I have not run any tests since before update.
Now
attempting to run a controller test give me the error:
‘migrations are pending’ with recommendation to run: bin/rake db:migrate
RAILS_ENV=test
when I run migrate on test I get error:
PGDuplicateTable relation ‘users’ already exists
If I run migration on production I do not get error. If I run the
following:
bundle exec rake db:migrate:reset RAILS_ENV=test
I can then run the test once, but trying to re-run gives me the
migration
pending error again.
Incidentally, my first project migration in migrations directory creates
users table:
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
…
This is my first rails app so I am wondering what is causing this and
how
to resolve. Any ideas?
background: I am developing on windows 7 with rspec testing and Postgres
database if any of that matters.
I decided to try it anyway with RAILS_ENV=test but I get same error of
duplicate table ‘users’ so I tried without the test env set and I get db
connection is closed message for test.
On Friday, January 30, 2015 at 6:42:19 AM UTC-5, Antônio Augusto Sousa
If I run:
bundle exec rake db:drop db:create db:migrate
I get error that db:migrate needs to be run with RAILS_ENV=test
if I
bundle exec rake db:drop db:create db:migrate RAILS_ENV=test
I get error regarding duplicate table again
If I delete db from postgres management screen then run
bundle exec rake db:drop db:create db:migrate RAILS_ENV=test
I can again run the test once, but the second time I get the error that
migrations are pending and to run db:migrate RAILS_ENV=test
I wonder why the act of running a simple test trigges this migration
message
I decided to try it anyway with RAILS_ENV=test but I get same error of duplicate
table ‘users’ so I tried without the test env set and I get db connection is
closed message for test.
I presume your development db is up to date (so running migrate on
that does nothing).
What happens if you recreate the test db and then run migrate on it?
Does the migrate run successfully?