[Rails] How to generate mapping with migration
Daniel Völkerts
daniel at voelkerts.de
Fri Apr 7 13:57:47 GMT 2006
Hi there, I've tried to add a m:n mapping table using the migration
mechanism.
ruby script\generate migration add_categories_notes_mapping
and filled the migration file with:
class AddNotesCategoriesMapping < ActiveRecord::Migration
def self.up
create_table :categories_notes do |t|
t.column :category_id, :integer, :null=>false
t.column :note_id, :integer, :null=>false
end
end
def self.down
drop_table :categories_notes
end
end
Now, I'd like to define both fields as primary key, but after I read the
API documentation, I'll wonder how I could pass to parameters to the
:primary parameter of create_table.
Any hints appreciated,
--
Daniel Völkerts
Protected by Anti Pesto. -- Wallace & Gromit
More information about the Rails
mailing list