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 trialYasir Ali
1,074 PointsMigrations are pending
After setting up the user from the generating the user model video. I get this error when I run the server and go to local host:
Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development
Rails.root: /Users/a/Desktop/treebook
2 Answers
Maciej Czuchnowski
36,441 PointsDid you manipulate any migration file AFTER they were migrated in the past? If so:
1) Don't do this ever again,
2) Run rake db:migrate:status
and paste the results here please.
Maciej Czuchnowski
36,441 PointsDo exactly what the error told you, or in short, type:
rake db:migrate
in the console and hit enter.
Yasir Ali
1,074 PointsI get this back:
== 20150101222931 AddDeviseToUsers: migrating ================================= -- change_table(:users) rake aborted! StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: duplicate column name: email: ALTER TABLE "users" ADD "email" varchar(255) DEFAULT '' NOT NULL/Users/a/Desktop/treebook/db/migrate/20150101222931_add_devise_to_users.rb:5:in block in up'
/Users/a/Desktop/treebook/db/migrate/20150101222931_add_devise_to_users.rb:3:in
up'
ActiveRecord::StatementInvalid: SQLite3::SQLException: duplicate column name: email: ALTER TABLE "users" ADD "email" varchar(255) DEFAULT '' NOT NULL
/Users/a/Desktop/treebook/db/migrate/20150101222931_add_devise_to_users.rb:5:in block in up'
/Users/a/Desktop/treebook/db/migrate/20150101222931_add_devise_to_users.rb:3:in
up'
SQLite3::SQLException: duplicate column name: email
/Users/a/Desktop/treebook/db/migrate/20150101222931_add_devise_to_users.rb:5:in block in up'
/Users/a/Desktop/treebook/db/migrate/20150101222931_add_devise_to_users.rb:3:in
up'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Gavin Ralston
28,770 PointsMaybe check that particular migration and see if you're trying to add the email column when it already exists in the users table?
(perhaps you didn't remove the email column in the down migration and reversed it at some point?)
Yasir Ali
1,074 PointsWhat I do notice is that in the video the guy doesn't have an add_devise_to_user.rb file but I do? I try deleting it and saving it but it comes back?
Yasir Ali
1,074 PointsI temporarily removed the file from the directory but it's still giving me the same error. Also, my file contains the same context and material as in the video.
Yasir Ali
1,074 PointsYasir Ali
1,074 PointsI think I did. This is what i get when I run that command:
database: /Users/a/Desktop/treebook/db/development.sqlite3
Status Migration ID Migration Name --------------------------------------------------....... up 20141217224759 Create statuses...... up 20141220204110 Devise create users........ down 20150101222931 Add devise to users
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsIf you did and if you don't have any important data in the database, you should destroy your database and recreate it using existing migrations. These commands in this order:
rake db:drop
rake db:create
rake db:migrate
And let me know what output you got after this last one.
If you did not tinker with databases, your migrations might have some conflicts. Please show me all your migration files.