Alex Rivera | Logout

Setting initial value for primary key in Rails (i.e. first object's id is 1000 instead of 1)

Asked 2009-06-23T13:34:14.143
10

What's the best way of going about this. Is there something I can put in the migrations? Thanks in advance.

Edit
Report

1 Answer

9

Any string passed into the ":options" option will be appended to the end of the SQL statement that creates the table. Best practice.

def self.up
    create_table :my_table, :options => "AUTO_INCREMENT = 1000" do |t|
      # ...
    end
end
answered 2009-06-23T13:46:01.390

Your Answer