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 Build a Simple Ruby on Rails Application Creating an Authentication System Generating the User Model

nawras nabil
nawras nabil
4,820 Points

Amending the devise db file after migrating it

Greetings, After generating the devise database file, I amended the devise db file by adding additional columns as shown in the video. These are “first name”,” last name” and “profile name”. However after migrating the data base file, I noticed that I did a typing mistake with the word “profile” (I wrote it as proile). Therefore, while adjusting the “new.html.erb” file I had to type misspelled word (Proile) to get the field on the page. I went back to the db file and corrected the misspelling then I re-migrated the db file again. However, it did not work as I still had to type the misspelled word in the “new.html.erb” page to get the field
Any idea how to amend the devise db file after migrating it?

3 Answers

Nick Fuller
Nick Fuller
9,027 Points

There are two ways to go about this.

  1. First, make the correction on the devise db file. Then you can completely drop your database bundle exec rake db:drop and then re-create it bundle exec rake db:create and then migrate it bundle exec rake db:migrate. This should fix the incorrect column name, but be warned this will destroy and re-create your database, so all data will be lost.

  2. Create a new migration that adjusts the column name in the table.

Since this is most likely a small project not yet in production, I would suggest going with option number 1.

Elena Newton
Elena Newton
39,588 Points

couldn't have said it better myself - i can't tell you how many times i've had to write a new migration to update a schema! if you can drop all and restart, do it :)

nawras nabil
nawras nabil
4,820 Points

Nick ... Thank you boss , this was helpful ,
Elena.. thank you for the advice:)