how do i reset a primary key id in ruby on rails 6?

The method does exist (as of Rails 6.0.0) for PostgreSQL:


Note that you are using SQLite:


So your available methods are here:

More importantly, YOU SHOULDN’T RESET YOUR TABLE IDS JUST BECAUSE YOU DELETED A USER. The database can handle incrementing the IDs no problem, even after you delete a user.

I’m having a hard time coming up with a use-case that would require resetting the Db Ids after deleting a record.

If you REALLY want to do this: Reset the id field in a table in a sqlite db in Rails

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top