I'd like the ID's of my Order model to start at 1000, and count up autoincrementally from there.
Can this be done via migration?
In your migration, after table has been created, update the sequence with something like this:
create_table :products do |t|
t.string :name
# other stuff
end
# for Postgres
execute "SELECT setval('products_id_seq', 1000)"
# and for mysql ...
execute "ALTER TABLE products AUTO_INCREMENT = 1000"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With