ruby on rails - Change starting id number -
i have 'account' model in rails corresponding 'accounts' table in database. if wipe database , start over, 'account_id' field start @ 1 , count there. change starting number, that, when first account created in fresh database, 'account_id' is, say, 1000. there way in rails, or need specialized database-dependent sql code?
for sake of illustration, here simplified version of 'accounts' table:
create_table "accounts", :force => true |t| t.string "email", :null => false t.string "crypted_password", :null => false t.string "name", :null => false t.boolean "email_verified", :default => false end
you'll need specialized database-dependent sql functionality.
if you're using mysql, can add following code migration after create_table
code:
execute("alter table tbl auto_increment = 1000")
Comments
Post a Comment