Search code examples
laravelregistration

Laravel registration method do not give next available id to new user


When a new user is registered through the registration form of Laravel framework, the id given to this new user is not the next id that exists in table users.

To give you an example, take a look to the next picture:

enter image description here

The id of the new registered user should be 6, and not 22.

What I assume is that for testing purposes I already have deleted some users from table users and that maybe the reason of the gap of ids.

Any ideas how to fix this?


Solution

  • Ids will not get reused, id column is using auto_increment by default

    1 - user 1
    2 - deleted
    3 - deleted
    4 - new user // new user will get id 4 not 2
    

    if you manually delete users when doing your tests you should reset auto_increment

    example with phpmyadmin

    enter image description here

    there is a AUTO_INCREMENT field you need to reset to the value you want