Hi guys! I'm really confused about this..
So, I created a Laravel app and hosted it on Heroku. I'm using ClearDB extension to be able to use MySQL. Problem is: when I save a new User on my DB, it is not being saved in ID order.
I got id 1, then id 11 for the second register, then id 21 for the third... Then I deleted them and tried again, and I got id 31. I think, there's a pattern, huh? It's going +10, +10... But why?
Look, the code I'm using to save a new register is only: DB::table('registers')->insert($registerData);
On the $registerData variable, I have only the following data: name, e-mail, a url for the picture and birth date.
When you create record in transaction and rollback it (because exception maybe), the auto-incremented value will be skipped.
Check application logs. And add migration code and action code to your question.
After deleting all the rows and creating new one you will took ID = LAST_DELETED_ROW_ID + 1
because MySQL stores increment counter in table meta (see this question: How to reset AUTO_INCREMENT in MySQL?).
Helpful answer: MySQL AUTO_INCREMENT does not ROLLBACK