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

robberbaron
robberbaron
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

Might 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.

robberbaron
robberbaron
23,869 Points

thank you very much. I gonna try that

Marc

Hi,

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
robberbaron
23,869 Points
class AddEmailAddress < ActiveRecord::Migration
  def up
    add_column :customers, :email, :string
  end

  def down
    remove_colum :customers, :email
  end
end

You'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
robberbaron
23,869 Points

thanks 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