Posted by Daniel Wed, 29 Mar 2006 20:34:17 GMT

So Rails has this great facility for controlling the database called migrations. Anyone who has worked with database backed apps for a while knows that one of the issues to be handled is keeping the database in sync with various app revisions… and when things go wrong… rolling the database back to the previous version. Rails has built in facilities for this. Nice. A migration contains two methods, an up and a down. Up is called when migrating forward so you build a table by saying something like

    def self.up
        create_table :events do |table|
          table.column :title, :string
          table.column :description, :string
          table.column :place, :string
          table.column :takes_place_on, :datetime
         end
  end

Rails convention adds an id column to this. But what if you wish to build an intermediate join table?

This will get you going:

create_table :table_name, :id => false do |table|
 ...
end