Migrations are pending; run 'bin/rake db:migrate RAILS_ENV=development' to resolve this issue [unable to proceed]

后端 未结 7 1711
盖世英雄少女心
盖世英雄少女心 2020-12-23 14:52

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

相关标签:
7条回答
  • 2020-12-23 15:12

    Check to make sure that table doesn't already exist:

    1. type - rails dbconsole
    2. type - .tables (check to see if there was an error during the rake db:migrate that has the table name like -- create_table(:test) rake aborted!)
    3. If you see the table name after running the .tables in the console type - drop table TABLENAME;
    4. Then .quit to go back to the branch and run the rake db:migrate command again.
    0 讨论(0)
  • 2020-12-23 15:16

    One weird trick that you can use when your migrations are screwed (file deleted, manually renamed, etc.)

    1. Fire up your favourite DB admin tool (eg. PGAdmin3) and browse to the database in question.
    2. Look for a table called 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.
    3. Make sure that your migration timestamps corresponds with the data in this column. If you have deleted an older migration, delete the corresponding timestamp.
    0 讨论(0)
  • 2020-12-23 15:18

    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

    0 讨论(0)
  • 2020-12-23 15:22

    try In RAILS_ROOT/config/environments/development.rb Set the following setting to false:

    config.active_record.migration_error = false#:page_load

    0 讨论(0)
  • 2020-12-23 15:27

    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.

    0 讨论(0)
  • 2020-12-23 15:29

    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'?

    0 讨论(0)
提交回复
热议问题