I'm mapping a new RoR application onto an existing Oracle schema. The
tables *usually* have a primary key named *id*, but the sequences that
assign new id values don't have Rails-convention names. Is there a way
to tell Rails that the sequence for table FOO is not FOO_SEQ, but
XYZ_SEQ?
If that's not possible, is there a way to create the equivalent of a
table's *view*, but for a sequence?
I got an answer from Railsfrance: set_sequence_name(value = nil,
&block) can be used. I hadn't been able to find the word "sequence" in
the index of the AWDwR2 book...
Yes, I did search the site for these keywords and other combinations.
I couldn't find an answer to my follow-up question:
The legacy Oracle schema uses triggers to get the sequences' next
values. Isn't there a potential conflict with Rails' mechanism during
record creation?
If so, should I tell Rails to use the existing trigger mechanism (and
how), or should I deactivate the triggers exclusively for my
application - the tables are being accessed by other legacy apps -
(and how)?
Last thought : I'm going to create views, so that I can use the Rails
naming conventions. Maybe that solves my problem, assuming I can link
the sequence to the view?
You can tell I'm new both to RoR and Oracle, can't you...
Thanks, Chris.
Le mécanisme d'affectation des clés primaires n'est pas clair, dans le
contexte de ma base existante : celle-ci utilise des "triggers" pour
récupérer la nouvelle valeur dans la séquence. Comment éviter un
conflit entre ceux-ci et Rails, lors de la création d'un nouvel
enregistrement ? Dois-je dire à Rails d'utiliser le mécanisme existant
(via "triggers") et comment ? Ou alors, dois-je inactiver les
"triggers" pour mon application (sachant que d'autres applis ont accès
à la même base) et comment ?
RoR et Oracle sont nouveaux pour moi ; ça se voit, non ?