0

How to set auto increment by 1 on a table in your migration script

ALTER TABLE Table_name AUTO_INCREMENT = 1;

Is it possible to mention this during table creation or after that, in your DB migration scripts.

Joe
  • 14,513
  • 28
  • 82
  • 144

1 Answers1

1

Maybe there are better solutions. Otherwise you can run raw SQL statements in migration scripts like this:

ActiveRecord::Base.connection.execute("ALTER TABLE Table_name AUTO_INCREMENT = 1")
Yanhao
  • 5,264
  • 1
  • 22
  • 15