Reset primary key sequence SQLite3
01 Mar 2023I was trying to reset the primary key sequence in a development Rails environment and realized the usual:
ActiveRecord::Base.connection.reset_pk_sequence!('users')
did not work. (I think that is a postgres exclusive method)
I did some digging and found that executing this raw SQL did work:
ActiveRecord::Base.connection.execute("UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='table_name'")
I learned from this post.