Hello, I''m using InstantRails 1.6 on Windows XP with Mysql 5.0.27, Rails 1.2.2, and Ruby 1.8.5. The following foreign key is not working. class FkLibriid < ActiveRecord::Migration def self.up execute "alter table my_items add constraint fk_myid foreign key (myid) references products(myid)" end def self.down end end I declared myid in both tables the same: t.column :myid, :integer, :null => false And myid is not primary key in any table. I don''t like it to be one. Additionally, I''ve set the following in the model for the referenced table: validates_uniqueness_of :myid C:\Myshop\shop>rake db:migrate --trace (in C:/Myshop/shop) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate == FkLibriid: migrating ======================================================-- execute("alter table my_items\n add constraint fk_myid \n foreign key (myid) references products(myid)") rake aborted! Mysql::Error: #HY000Can''t create table ''.\shop_development \#sql-464_23.frm'' (err no: 150): alter table my_items add constraint fk_myid foreign key (myid) references products(myid) It would be nice if someone could help me. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---