Yet another primary key and migrations question

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…)

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.

On Mon, 17 Dec 2007 18:34:31 +0100, Damaris F. 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?” :wink:

-Thufir

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs