Before visiting the test data in the DB table, I need to truncate the table (I need to reset the primary key), I try to do this as follows:
ActiveRecord::Base.connection.execute("TRUNCATE users")
but when I print the data from the database, I still do not see the primary key counting from 1.
What am I doing wrong?
EDIT:
In addition, I tried to manually start the PostgreSQL database in the terminal
truncate users
But the primary account does not start at 1.
DECISION:
In Postgres, run:
ALTER SEQUENCE users_id_seq RESTART WITH 1;
source
share