Alternate primary key for legacy data

I have a “journals” table (created with a rails migration but with “id”
renamed to “id_journal”) with auto-incrementing primary key
“id_journal”.

class Journal < ActiveRecord::Base
set_primary_key “id_journal”
end

Despite using set_primary_key in the Journal model, I get the following
error:

Mysql::Error: Failed to read auto-increment value from storage engine:
INSERT INTO journals (jname, created_at, updated_at,
has_full_text_online, iscomplete, publisher, flagged, issn,
instance, link, subjects) VALUES(‘Actas Dermo-Sifiliográficas
(English Edition)’, ‘2010-04-14 04:27:42’, ‘2010-04-14 04:27:42’, NULL,
0, ‘’, 0, ‘’, ‘SD-1’, ‘’, ‘’)

Is this an issue with ActiveRecord not recognizing the primary key, or
an issue with how the database is setup? Everything worked fine when the
field was named “id”.

Thanks in advance!

Ben

No. set_primary_key should work. But looks like a mysql error.
There looks like mysql unable to do auto-increment. Please search
online regarding this mysql error.

Try in the Irb, setting up the primary key value explicitly.

Like,
Journal.insert(:id_journal=>100, :jname=>‘Actas Dermo-Sifiliográficas’)
and see the result. If this is accepted, then, some issue with
auto-increment.

Cheers
Amala

On 14 April 2010 19:52, Ben V. [email protected] wrote:

For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Nandri(Thanks in Tamil),
Amala S.