class CreateContactgroups < ActiveRecord::Migration def self.up create_table :contactgroups do |t| t.column :groupname, :string t.column :contact_id, :integer, :null => false end execute "alter table contactgroups add constraint fk_contactgroups_contacts foreign key (contact_id) references contacts(id)" end def self.down drop_table :contactgroups end end