Migration problem

Ok, going through the book Ruby on Rails Made Easy, and I made a mistake here. I forgot to add in two columns into my table. so i tried to add them back into the migration file and run it again, but after checking with the #ROR channel on IRC i was informed that this is not possible. I needed to make a new migration file.

I have done this, but I am obviously doing something wrong. If someone could point out my error it would be appreciated.

Original migration file.

class CreateCategories < ActiveRecord::Migration   def self.up     create_table :categories do |t|       t.column :name, :string     end

    Category.create :name => "Furniture"     Category.create :name => "Miscellaneous"

    add_column :classifieds, :category_id, :integer     Classified.find(:all).each do |c|       c.update_attribute(:category_id, 4)       end   end

  def self.down     drop_table :categories     remove_column :classifieds, :category_id   end end

Migration file I tried to create.

class AddColumns < ActiveRecord::Migration   def self.up   create_t.column :name, :string     end

    Category.create :name => "Electronics"     Category.create :name => "Real Estate"   end

  def self.down      drop_table :categories     remove_column :classifieds, :category_id   end end

receive an unexpected kEND expecting $ error when trying to run rake db:migrate on the new file.

Thank you,

Dave

I have done this, but I am obviously doing something wrong. If someone could point out my error it would be appreciated.

Migration file I tried to create.

class AddColumns < ActiveRecord::Migration def self.up create_t.column :name, :string end

Oops, self.up is ended here, but you continue to write migration up code, delete this end statement

You only need to create create a new migration file to add columns if you've already put your app into production.

If you're just following a tutorial, just edit the migration you have. Then run rake db:migrate VERSION=0 to drop everything and then rake db:migrate to set up the db again with your new migration.

b

wheresdave wrote:

awesome.

thank you so much.