0

I created a new rails 4 engine and added a model. I am trying to migrate the database using

RAILS_ENV=test rake db:migrate

and it comes back with no errors. However, when I run:

rspec spec

an error returns stating there are pending migrations.

Migrations are pending; run 'rake db:migrate RAILS_ENV=test' to resolve this issue. (ActiveRecord::PendingMigrationError)

It's true if I look at my database (tried on pg and sqlite) that they have not been run and no tables have been created. Running the suggested command listed above does not run the migrations.

There is only one migration in 'engine_name/db/migrate', and no migrations inside the dummy app.

I am using ruby 2.0 and rails 4.0.0.rc1.

tshepang
  • 12,111
  • 21
  • 91
  • 136
anthony
  • 391
  • 1
  • 3
  • 15

3 Answers3

5

You need to copy migrations into dummy app rake app:<engine_name>:install:migrations

mikdiet
  • 9,859
  • 8
  • 59
  • 68
1

Add code in your engine task

https://gist.github.com/doabit/5692865 .

doabit
  • 68
  • 6
0

I've experienced this same issue. doabit's fix worked for me. thanks! There is an open issue for this with the rails core team. https://github.com/rails/rails/issues/10622

AJ.
  • 1,248
  • 10
  • 27