Rails database migration error

1.6k views Asked by At

I wanna get started with ror but this problem seems unsolvable. I know there are many threads about it this database error but none of the solutions appear to work out. I now searched through the forums all afternoon, with no success.

I basically just perform the first tasks from the textbook, which are as follows: I create a new RoR project (Windows 10, SQLite3) with

rails new depot

Then I create a scaffold in this project with the following code:

rails generate scaffold Product title:string description:text image_url:string price:decimal

And as i test the application I get the db:migrate error. I tried rake db:migrate, db:rollback, db:drop and then db:create, I checked the migration file for mistakes, but nothing appears to work.

I assume the solution should be quite simple, since the application should be as uncomplex as it gets at this state, but I just cannot get behind the secret it appears.

Migrations are pending. To resolve this issue, run:

    bin/rails db:migrate RAILS_ENV=test

    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/migration.rb:586:in `load_schema_if_pending!'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/migration.rb:592:in `block in maintain_test_schema!'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/migration.rb:823:in `suppress_messages'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/migration.rb:597:in `method_missing'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/migration.rb:592:in `maintain_test_schema!'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_help.rb:15:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `block in require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
    from C:/Users/Flori/Desktop/bsp/test/test_helper.rb:3:in `<top (required)>'
    from C:/Users/Flori/Desktop/bsp/test/controllers/products_controller_test.rb:1:in `require'
    from C:/Users/Flori/Desktop/bsp/test/controllers/products_controller_test.rb:1:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:11:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:11:in `block in require_files'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:10:in `each'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:10:in `require_files'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_unit/minitest_plugin.rb:86:in `plugin_rails_init'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/minitest-5.10.1/lib/minitest.rb:80:in `block in init_plugins'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/minitest-5.10.1/lib/minitest.rb:78:in `each'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/minitest-5.10.1/lib/minitest.rb:78:in `init_plugins'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/minitest-5.10.1/lib/minitest.rb:129:in `run'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_unit/minitest_plugin.rb:73:in `run'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/minitest-5.10.1/lib/minitest.rb:62:in `block in autorun'
1

There are 1 answers

0
Che On

Switch of your server, then run

rake db:drop db:create db:migrate 

This must fix your problem