References in Rails 2.0 migrations

I've searched around and have not found a way to add a reference column to an existing table, I guess it would be something like

class AddProjectReferenceToTask < ActiveRecord::Migration   def self.up     add_reference :tasks, :projects

  end

  def self.down    remove_reference :tasks, :projects   end end

of course the methods don't exist but you get an idea of what the problem is, man I need that AWDR for 2.0...

Um, you mean an association, right?

I’m assuming it’s a HABTM one, def self.up create_table :projects_tasks, :id => false do |t| t.integer :project_id, :task_id end end self

def self.down

drop_table :projects_tasks end

now I see what the problem was, I thought that by doing t.references :project the migration would do the reference on mysql, instead of just creating the field for the FK.

It's a one to many so all I had to do to add the reference was

add_column :tasks, :project_id, :integer