views:

61

answers:

1

I have a postgres table and a schema that creates a primary id (sequence) that auto increments by 1. How do I specify the starting value? I am happy with the increment value. Here is my schema migration:

create_table "ServiceProvider", {:primary_key => :ID} do |t|
  t.integer "ID",                       :null => false
end

Thank you

A: 

Use this option :

create_table "ServiceProvider",:options => "AUTO_INCREMENT = 1234" do |t|
  ...
end

But be carefull, this wouldn't work with ALL database management systems. I know this should work with MySQL but you might want to double check for postgres.

marcgg
I'm sorry, I don't want to change the auto_increment value, I specifically said I am happy with it incrementing by 1, I want to change the "Starting Value". Thank you
RewbieNewbie
@RewbieNewbie: I believe that's what that does, it makes 1234 the starting value.
JRL
create_table "ServiceProvider", {:primary_key => :ID, :options => "AUTO_INCREMENT = 1234"}Returns error message:RuntimeError: ERROR C42601 Msyntax error at or near "AUTO_INCREMENT"
RewbieNewbie