Primary key storing strings

Can a ':primary_key' to store strings or has to be integers?

t.primary_key :text_code

From a databases perspective, a string could easily be a primary key. What are you looking at acheiving, could you do it using validates_uniquness_of :xyz ?

Cheers,
James

James Brooks ha escrito:

From a databases perspective, a string could easily be a primary key. What
are you looking at acheiving, could you do it using validates_uniquness_of
:xyz ?

No, I need a string as primary key. I hope to have not any problem.

Thanks

Solved!

Primary key for a string field of until 3 characters:

create_table :cars, :id => false, :primary_key => :alpha_code do |t|
      t.string :alpha_code, :limit => 3

In PSQL isn't showed the primary key. I'm supposed that you have to
exec the sql yourself to add the primary key constraint.

Conclussion: it's better don't go against rails' standard practices.