Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby on Rails 5 Basics Adding a Model Attribute Updating the Model

Daniel Sokol
Daniel Sokol
14,888 Points

bin/rake db:migrate error....

Hi all,

I was able to run:

 bin/rails generate migration AddBodyToPosts body:text

However, when I run:

 bin/rake db:migrate

I get this error:

StandardError: An error has occurred, this and all later migrations canceled:

SQLite3::SQLException: no such table: servers: ALTER TABLE "servers" ADD "body" text /Users/Dan/blog/db/migrate/20160917000552_add_body_to_server.rb:3:in change' -e:1:in<main>' ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: servers: ALTER TABLE "servers" ADD "body" text /Users/Dan/blog/db/migrate/20160917000552_add_body_to_server.rb:3:in change' -e:1:in<main>' SQLite3::SQLException: no such table: servers /Users/Dan/blog/db/migrate/20160917000552_add_body_to_server.rb:3:in change' -e:1:in<main>' Tasks: TOP => db:migrate (See full trace by running task with --trace)

Not sure what to do now....tried Googling for an answer, but couldn't figure it out.

Thanks,.

5 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey Daniel,

In Rails 5, this has changed. They are trying to keep everything kind of in the same place, so try running (what is the new Rails 5 command)...

bin/rails db:migrate

That should work. :) :dizzy:

Daniel Sokol
Daniel Sokol
14,888 Points

Hi Jason, thanks for your quick response. I should have mentioned that I tried that command first and got this:

Error: Command 'db:migrate' not recognized Did you mean: $ rake db:migrate ?

Usage: rails COMMAND [ARGS]

The most common rails commands are: generate Generate new code (short-cut alias: "g") console Start the Rails console (short-cut alias: "c") server Start the Rails server (short-cut alias: "s") dbconsole Start a console for the database specified in config/database.yml (short-cut alias: "db") new Create a new Rails application. "rails new my_app" creates a new application called MyApp in "./my_app"

In addition to those, there are: destroy Undo code generated with "generate" (short-cut alias: "d") plugin new Generates skeleton for developing a Rails plugin runner Run a piece of code in the application environment (short-cut alias: "r")

All commands can be run with -h (or --help) for more information.

Thanks........

Daniel Sokol
Daniel Sokol
14,888 Points

Also, I am running on Rails 4.2.6

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

That would be it. You are doing the Rails 5 course and 4.2.6 will not work for this course. You'll need to set up for a Rails 5 environment. Treehouse has a workshop (7 minutes) on how to do this.

For Mac

For Windows

For Linux

Hope it all gets figured for you. :)

Daniel Sokol
Daniel Sokol
14,888 Points

Thanks so much for your quick responses. I followed the directions on the video and I am now running on Rails 5.0.0.1.

But I was still getting the same errors, maybe because I created the blog directory using the old version?

So I decided to remove the blog directory (rm -r blog) and start the whole thing all over from scratch.....

Now it works!

Thank you!!

I got a problem when I run the command:

"bin/rails generate migration AddBodyToPosts body:text and then:

"bin/rails db:migrate"

"[NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html"

My best guess is that it occurs when trying to add a new column in the database. Any ideas?