Rails Migration with adding and removing reference

After creating a migration file with rails generate migration AddClientToUser I can edit my migration file like so:

class AddClientToUser < ActiveRecord::Migration
  def self.up
    change_table :users do |t|
      t.references :client
    end
  end

  def self.down
    change_table :users do |t|
      t.remove :client_id
    end
  end
end

Is this the correct way to reverse the reference column added in the migration?

43
задан Matt Connolly 13 April 2011 в 12:12
поделиться