Hi I'd like to have a varchar primary key named id instead of the default int id. Does anyone knows how to specify this from migrations ? Should I also specify something in the model class ? thanks! Thibaut
on 2006-03-12 23:02
on 2006-03-13 08:39
Ya probably just...do it. You probably also want some kind of iterator/sequence/generator/trigger in place to supply new values automatically on insert. What you should probably also do is create a table that stores the last value used, so as to avoid the "select max(id) from mytable..." brute force logic as well as any transaction issues, things that sequences/generators do for you already in a transaction-safe manner.
on 2006-03-13 12:07
Hi! well when I add a column under migration, the type can be either :string, :integer, or :primary_key. I can't seem to find how to have it defined as both a :string and a :primary_key. Or should I add custom sql ?
on 2006-03-13 13:35
Thibaut BarrÃ¨re wrote: > Hi > > I'd like to have a varchar primary key named id instead of the default > int > id. Does anyone knows how to specify this from migrations ? The Agile book suggest setting up a two primary ids - the first a new one : int auto incremented and a second one your legacy pk _tony
on 2006-03-14 01:18
Thibaut Barrère wrote: > Hi can you just call the primary_key() method in your model class (your subclass of ActiveRecord::Base)? The RDocs: primary_key() Defines the primary key field ? can be overridden in subclasses. Overwriting will negate any effect of the primary_key_prefix_type setting, though.
on 2006-03-14 01:30
Doh, I am sorry, I should have read that you mentioned Migrations. Sorry, nothing to see from me.