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 trialrobberbaron
23,869 Points:email not inserted in schema while doing migrations
Hi!
While doing the Active Record Training - in the Migrations-Part Hampton is showing the up and down part where he inserts the :email. Unfortunatelly the :email does not get into my schema while migrating. Also a rollback with subsequent migration did not help. Any help how to fix this?
Cheers Marc
3 Answers
Steve Hunter
57,712 PointsMight be worth trying a rake db:reset
which drops the DB and rebuilds it. You'll lose content, though - not that it matters as the course will lead you a merry dance with fake data etc. Enjoy the ride!
I just Googled a S.O. post on this topic: http://stackoverflow.com/questions/20464924/rails-migration-does-not-change-schema-rb
Good luck!
Steve.
Steve Hunter
57,712 PointsHi,
Can you post your code for the addition of the :email and the resulting messages, if any? Does it create a migration file? (post that too!)
Steve.
robberbaron
23,869 Pointsclass AddEmailAddress < ActiveRecord::Migration
def up
add_column :customers, :email, :string
end
def down
remove_colum :customers, :email
end
end
Steve Hunter
57,712 PointsYou've missed the letter 'n' out of remove_column
- could that be the issue?
My code looks like:
class AddEmailAddress < ActiveRecord::Migration
def up
add_column :customers, :email, :string
end
def down
remove_column :customers, :email
end
end
Steve.
robberbaron
23,869 Pointsthanks for finding this error - however email does not show up in customers
ActiveRecord::Schema.define(version: 20150525182838) do
create_table "customers", force: true do |t|
t.string "name"
t.string "about"
t.date "balance"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "employees", force: true do |t|
t.string "name"
t.string "email"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "time_entries", force: true do |t|
t.float "time"
t.integer "customer_id"
t.integer "employee_id"
t.datetime "created_at"
t.datetime "updated_at"
end
end
robberbaron
23,869 Pointsrobberbaron
23,869 Pointsthank you very much. I gonna try that
Marc