I''ve read the messages concerning this issue, but I haven''t come to a conclusion. I have a legacy db with data I have to import to my new app, as it is. So I can''t use the auto-increment "id" my migrations generate. I''ve done the following: create_table(:results, :id => false, :primary_key => ''code'' ) do |t| t.column :code, :integer But, in my SQL server, "code" does not appear as primary key. So, what can I do to make so? And if I use the set_primary_key in the model, it does not solve anything... I mean, this primary key in SQL server will not be set to primary key (so I think I won''t use the migrations at all...) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''ve done the following: create_table(:interpretations, :id=> false) do |t| t.column :code, :integer t.column :descripcion, :string, :limit => 80 end execute "ALTER TABLE `interpretations` ADD PRIMARY KEY (`code`)" But now I have to state that primary key is "code" also in the model. So this is not DRY anymore. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Mon, 17 Dec 2007 18:34:31 +0100, Damaris Fuentes wrote:> execute "ALTER TABLE `interpretations` ADD PRIMARY KEY (`code`)" > > But now I have to state that primary key is "code" also in the model. So > this is not DRY anymore.Wouldn''t the lingo be: "how to DRY out the above code?" ;) -Thufir --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---